~golang-logging/golang-logging/trunk

« back to all changes in this revision

Viewing changes to logger_test.go

  • Committer: Örjan Persson
  • Date: 2016-02-11 22:40:43 UTC
  • Revision ID: git-v1:c81bd2bad6f4164e6fe6c7c5f867ee6325939c1c
Make Info and Infof etc distinct different functions

This change breakes backwards compatibility. See CHANGELOG for details.
Sorry if this broke your log output but this one was overdue.

Fixes #52.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        backend := InitForTesting(DEBUG)
30
30
        password := Password("123456")
31
31
        log := MustGetLogger("test")
32
 
        log.Debug("foo %s", password)
 
32
        log.Debug("foo", password)
33
33
        if "foo ******" != MemoryRecordN(backend, 0).Formatted(0) {
34
34
                t.Errorf("redacted line: %v", MemoryRecordN(backend, 0))
35
35
        }
36
36
}
37
37
 
 
38
func TestRedactf(t *testing.T) {
 
39
        backend := InitForTesting(DEBUG)
 
40
        password := Password("123456")
 
41
        log := MustGetLogger("test")
 
42
        log.Debugf("foo %s", password)
 
43
        if "foo ******" != MemoryRecordN(backend, 0).Formatted(0) {
 
44
                t.Errorf("redacted line: %v", MemoryRecordN(backend, 0).Formatted(0))
 
45
        }
 
46
}
 
47
 
38
48
func TestPrivateBackend(t *testing.T) {
39
49
        stdBackend := InitForTesting(DEBUG)
40
50
        log := MustGetLogger("test")
49
59
        if "to private baсkend" == MemoryRecordN(privateBackend, 0).Formatted(0) {
50
60
                t.Error("logged to defaultBackend:", MemoryRecordN(privateBackend, 0))
51
61
        }
52
 
 
53
62
}