|
@@ -13,6 +13,7 @@ type ConsoleBackend struct {
|
|
|
s_fc_json_key func(string) string
|
|
|
s_fc_json_val func(string) string
|
|
|
s_lvd []func(string) string
|
|
|
+ enable bool
|
|
|
}
|
|
|
|
|
|
func NewConsoleBackend(wr io.Writer) *ConsoleBackend {
|
|
@@ -29,11 +30,19 @@ func NewConsoleBackend(wr io.Writer) *ConsoleBackend {
|
|
|
chalk.Cyan.NewStyle().Style,
|
|
|
chalk.Blue.NewStyle().Style,
|
|
|
},
|
|
|
+ enable: true,
|
|
|
}
|
|
|
return scb
|
|
|
}
|
|
|
|
|
|
+func (b *ConsoleBackend) Shutdown() {
|
|
|
+ b.enable = false
|
|
|
+}
|
|
|
+
|
|
|
func (b *ConsoleBackend) EmitStringLog(module string, level hiedalog.HiedaLogLevel, content string) {
|
|
|
+ if !b.enable {
|
|
|
+ return
|
|
|
+ }
|
|
|
var lv string
|
|
|
if level.LevelNumber < 7 {
|
|
|
lv = b.s_lvd[level.LevelNumber](level.Name)
|
|
@@ -44,6 +53,9 @@ func (b *ConsoleBackend) EmitStringLog(module string, level hiedalog.HiedaLogLev
|
|
|
}
|
|
|
|
|
|
func (b *ConsoleBackend) EmitComplexLog(module string, level hiedalog.HiedaLogLevel, data map[string]string) {
|
|
|
+ if !b.enable {
|
|
|
+ return
|
|
|
+ }
|
|
|
b.EmitStringLog(module, level, b.prettyComplexToString(data))
|
|
|
}
|
|
|
|