author | Chris Jones <christian.jones@sri.com> |
Sun, 15 Sep 2013 11:34:35 -0600 | |
changeset 142 | 0ff033eed887 |
parent 126 | 367e76b3028e |
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 |
// 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
|
2 |
|
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 |
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
|
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 |
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
|
6 |
// 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
|
7 |
// 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
|
8 |
// severity. |
116 | 9 |
Warn Logger = &noLog{} |
10 |
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
|
11 |
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
|
12 |
) |
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 |
|
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 |
// 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
|
15 |
// 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
|
16 |
// 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
|
17 |
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
|
18 |
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
|
19 |
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
|
20 |
} |
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 |
|
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 |
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
|
23 |
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
|
24 |
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
|
25 |
} |
116 | 26 |
|
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
|
27 |
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
|
28 |
|
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 |
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
|
30 |
} |
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) 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
|
33 |
} |