author | Chris Jones <christian.jones@sri.com> |
Sat, 07 Sep 2013 10:04:44 -0700 | |
changeset 126 | 367e76b3028e |
parent 116 | log.go@5c6d6d51d3ba |
child 142 | 0ff033eed887 |
permissions | -rw-r--r-- |
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 | 13 |
Warn Logger = &noLog{} |
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 | 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 |
} |