@@ -14,28 +14,29 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- package core
17
+ package flogging_test
18
18
19
19
import (
20
20
"testing"
21
21
22
+ "github.com/hyperledger/fabric/flogging"
22
23
"github.com/op/go-logging"
23
24
"github.com/spf13/viper"
24
25
)
25
26
26
27
func TestLoggingLevelDefault (t * testing.T ) {
27
28
viper .Reset ()
28
29
29
- LoggingInit ("" )
30
+ flogging . LoggingInit ("" )
30
31
31
- assertDefaultLoggingLevel (t , DefaultLoggingLevel ())
32
+ assertDefaultLoggingLevel (t , flogging . DefaultLoggingLevel ())
32
33
}
33
34
34
35
func TestLoggingLevelOtherThanDefault (t * testing.T ) {
35
36
viper .Reset ()
36
37
viper .Set ("logging_level" , "warning" )
37
38
38
- LoggingInit ("" )
39
+ flogging . LoggingInit ("" )
39
40
40
41
assertDefaultLoggingLevel (t , logging .WARNING )
41
42
}
@@ -44,7 +45,7 @@ func TestLoggingLevelForSpecificModule(t *testing.T) {
44
45
viper .Reset ()
45
46
viper .Set ("logging_level" , "core=info" )
46
47
47
- LoggingInit ("" )
48
+ flogging . LoggingInit ("" )
48
49
49
50
assertModuleLoggingLevel (t , "core" , logging .INFO )
50
51
}
@@ -53,7 +54,7 @@ func TestLoggingLeveltForMultipleModules(t *testing.T) {
53
54
viper .Reset ()
54
55
viper .Set ("logging_level" , "core=warning:test=debug" )
55
56
56
- LoggingInit ("" )
57
+ flogging . LoggingInit ("" )
57
58
58
59
assertModuleLoggingLevel (t , "core" , logging .WARNING )
59
60
assertModuleLoggingLevel (t , "test" , logging .DEBUG )
@@ -63,7 +64,7 @@ func TestLoggingLevelForMultipleModulesAtSameLevel(t *testing.T) {
63
64
viper .Reset ()
64
65
viper .Set ("logging_level" , "core,test=warning" )
65
66
66
- LoggingInit ("" )
67
+ flogging . LoggingInit ("" )
67
68
68
69
assertModuleLoggingLevel (t , "core" , logging .WARNING )
69
70
assertModuleLoggingLevel (t , "test" , logging .WARNING )
@@ -73,7 +74,7 @@ func TestLoggingLevelForModuleWithDefault(t *testing.T) {
73
74
viper .Reset ()
74
75
viper .Set ("logging_level" , "info:test=warning" )
75
76
76
- LoggingInit ("" )
77
+ flogging . LoggingInit ("" )
77
78
78
79
assertDefaultLoggingLevel (t , logging .INFO )
79
80
assertModuleLoggingLevel (t , "test" , logging .WARNING )
@@ -83,7 +84,7 @@ func TestLoggingLevelForModuleWithDefaultAtEnd(t *testing.T) {
83
84
viper .Reset ()
84
85
viper .Set ("logging_level" , "test=warning:info" )
85
86
86
- LoggingInit ("" )
87
+ flogging . LoggingInit ("" )
87
88
88
89
assertDefaultLoggingLevel (t , logging .INFO )
89
90
assertModuleLoggingLevel (t , "test" , logging .WARNING )
@@ -93,53 +94,53 @@ func TestLoggingLevelForSpecificCommand(t *testing.T) {
93
94
viper .Reset ()
94
95
viper .Set ("logging.node" , "error" )
95
96
96
- LoggingInit ("node" )
97
+ flogging . LoggingInit ("node" )
97
98
98
99
assertDefaultLoggingLevel (t , logging .ERROR )
99
100
}
100
101
101
102
func TestLoggingLevelForUnknownCommandGoesToDefault (t * testing.T ) {
102
103
viper .Reset ()
103
104
104
- LoggingInit ("unknown command" )
105
+ flogging . LoggingInit ("unknown command" )
105
106
106
- assertDefaultLoggingLevel (t , DefaultLoggingLevel ())
107
+ assertDefaultLoggingLevel (t , flogging . DefaultLoggingLevel ())
107
108
}
108
109
109
110
func TestLoggingLevelInvalid (t * testing.T ) {
110
111
viper .Reset ()
111
112
viper .Set ("logging_level" , "invalidlevel" )
112
113
113
- LoggingInit ("" )
114
+ flogging . LoggingInit ("" )
114
115
115
- assertDefaultLoggingLevel (t , DefaultLoggingLevel ())
116
+ assertDefaultLoggingLevel (t , flogging . DefaultLoggingLevel ())
116
117
}
117
118
118
119
func TestLoggingLevelInvalidModules (t * testing.T ) {
119
120
viper .Reset ()
120
121
viper .Set ("logging_level" , "core=invalid" )
121
122
122
- LoggingInit ("" )
123
+ flogging . LoggingInit ("" )
123
124
124
- assertDefaultLoggingLevel (t , DefaultLoggingLevel ())
125
+ assertDefaultLoggingLevel (t , flogging . DefaultLoggingLevel ())
125
126
}
126
127
127
128
func TestLoggingLevelInvalidEmptyModule (t * testing.T ) {
128
129
viper .Reset ()
129
130
viper .Set ("logging_level" , "=warning" )
130
131
131
- LoggingInit ("" )
132
+ flogging . LoggingInit ("" )
132
133
133
- assertDefaultLoggingLevel (t , DefaultLoggingLevel ())
134
+ assertDefaultLoggingLevel (t , flogging . DefaultLoggingLevel ())
134
135
}
135
136
136
137
func TestLoggingLevelInvalidModuleSyntax (t * testing.T ) {
137
138
viper .Reset ()
138
139
viper .Set ("logging_level" , "type=warn=again" )
139
140
140
- LoggingInit ("" )
141
+ flogging . LoggingInit ("" )
141
142
142
- assertDefaultLoggingLevel (t , DefaultLoggingLevel ())
143
+ assertDefaultLoggingLevel (t , flogging . DefaultLoggingLevel ())
143
144
}
144
145
145
146
func assertDefaultLoggingLevel (t * testing.T , expectedLevel logging.Level ) {
0 commit comments