log.go
author Chris Jones <christian.jones@sri.com>
Fri, 30 Aug 2013 17:24:39 -0600
changeset 118 fb9bb98a8d70
parent 116 5c6d6d51d3ba
permissions -rw-r--r--
Code cleanup: Renamed the Version constant. Moved the unique-ID generator into its own file.
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.
116
Chris Jones <christian.jones@sri.com>
parents: 102
diff changeset
    13
	Warn  Logger = &noLog{}
Chris Jones <christian.jones@sri.com>
parents: 102
diff changeset
    14
	Info  Logger = &noLog{}
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
    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
}
116
Chris Jones <christian.jones@sri.com>
parents: 102
diff changeset
    30
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
    31
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
    32
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
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
    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
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
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
    37
}