xmpp/log.go
changeset 126 367e76b3028e
parent 116 5c6d6d51d3ba
child 142 0ff033eed887
equal deleted inserted replaced
125:f464f14e39a7 126:367e76b3028e
       
     1 // Copyright 2011 The Go Authors.  All rights reserved.
       
     2 // Use of this source code is governed by a BSD-style
       
     3 // license that can be found in the LICENSE file.
       
     4 
       
     5 // Control over logging from the XMPP library.
       
     6 
       
     7 package xmpp
       
     8 
       
     9 var (
       
    10 	// If any of these are non-nil when NewClient() is called,
       
    11 	// they will be used to log messages of the indicated
       
    12 	// severity.
       
    13 	Warn  Logger = &noLog{}
       
    14 	Info  Logger = &noLog{}
       
    15 	Debug Logger = &noLog{}
       
    16 )
       
    17 
       
    18 // Anything implementing Logger can receive log messages from the XMPP
       
    19 // library. The default implementation doesn't log anything; it
       
    20 // efficiently discards all messages.
       
    21 type Logger interface {
       
    22 	Log(v ...interface{})
       
    23 	Logf(fmt string, v ...interface{})
       
    24 }
       
    25 
       
    26 type noLog struct {
       
    27 	flags  int
       
    28 	prefix string
       
    29 }
       
    30 
       
    31 var _ Logger = &noLog{}
       
    32 
       
    33 func (l *noLog) Log(v ...interface{}) {
       
    34 }
       
    35 
       
    36 func (l *noLog) Logf(fmt string, v ...interface{}) {
       
    37 }