Commit 27a98a14
27a98a14f138Merged
zhilyaev <[email protected]> ยท 5 years ago ยท 1 file ยท ~1 modified
Description
color log fields
Details
- Commit
- 27a98a14f138
- Parent
- 64756f26f6e2
pkg/formatter/func.gomodifiedView file
@@ -9,6 +9,8 @@
99
var emojisLevel = [7]string{"๐", "๐คฌ", "๐ฉ", "๐", "๐", "๐คท", "๐คฎ"}1010
var colors = [7]string{"[44;1m", "[31;1m", "[31;1m", "[33m", "[36m", "[37;1m", "[35;1m"}1111
12+
const LogFieldColor = "[35;1m"13+
1214
const Start = "\033"1315
const End = Start + "[0m"1416
@@ -30,10 +32,12 @@
3032
emoji := emojisLevel[i]3133
l := level3234
m := entry.Message35+
fieldPattern := "%s"3336
if f.Color {3437
color := colors[i]3538
l = Start + color + level + End3639
m = Start + color + entry.Message + End40+
fieldPattern = Start + LogFieldColor + fieldPattern + End3741
}3842
3943
output = strings.Replace(output, "%time%", entry.Time.Format(timestampFormat), 1)@@ -45,9 +49,9 @@
4549
switch val.(type) {4650
case []string:4751
v := strings.Join(val.([]string), "\n\t - ")48-
output += fmt.Sprintf("\n\t%s: \n\t - %v", k, v)52+
output += fmt.Sprintf("\n\t"+fieldPattern+": \n\t - %v", k, v)4953
default:50-
output += fmt.Sprintf("\n\t%s: %v", k, val)54+
output += fmt.Sprintf("\n\t"+fieldPattern+": %v", k, val)5155
}5256
//strings.Join(s, ", "5357
//output += fmt.Sprintf("\n\t%s: %v", k, val)