log.go
author Chris Jones <christian.jones@sri.com>
Fri, 28 Dec 2012 17:07:20 -0700
changeset 114 a058e33c1666
parent 102 872e936f9f3f
child 116 5c6d6d51d3ba
permissions -rw-r--r--
Updated for the latest revision of the encoding/xml fixes: The context object owned by Encoder and Decoder isn't directly accessible. Also improved the output from the two assert functions to show the info of the caller rather than the assert function itself.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
102
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     1
// Copyright 2011 The Go Authors.  All rights reserved.
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     2
// Use of this source code is governed by a BSD-style
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     3
// license that can be found in the LICENSE file.
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     4
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     5
// Control over logging from the XMPP library.
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     6
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     7
package xmpp
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     8
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
     9
var (
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    10
	// If any of these are non-nil when NewClient() is called,
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    11
	// they will be used to log messages of the indicated
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    12
	// severity.
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    13
	Warn Logger = &noLog{}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    14
	Info Logger = &noLog{}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    15
	Debug Logger = &noLog{}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    16
)
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    17
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    18
// Anything implementing Logger can receive log messages from the XMPP
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    19
// library. The default implementation doesn't log anything; it
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    20
// efficiently discards all messages.
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    21
type Logger interface {
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    22
	Log(v ...interface{})
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    23
	Logf(fmt string, v ...interface{})
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    24
}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    25
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    26
type noLog struct {
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    27
	flags  int
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    28
	prefix string
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    29
}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    30
var _ Logger = &noLog{}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    31
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    32
func (l *noLog) Log(v ...interface{}) {
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    33
}
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    34
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    35
func (l *noLog) Logf(fmt string, v ...interface{}) {
872e936f9f3f Reworked the logging again, and also added namespaces to a couple of fields on Features.
Chris Jones <christian.jones@sri.com>
parents:
diff changeset
    36
}