Fix pretty logging and add a screenshot to the README

This commit is contained in:
Olivier Poitrey 2017-08-05 20:45:41 -07:00
parent 90fdb63d84
commit 2ed2f2c974
4 changed files with 5 additions and 2 deletions

View File

@ -10,6 +10,8 @@ The uber's [zap](https://godoc.org/go.uber.org/zap) library pioneered this appro
To keep the code base and the API simple, zerolog focuses on JSON logging only. Pretty logging on the console is made possible using the provided `zerolog.ConsoleWriter`.
![](pretty.png)
## Features
* Blazing fast

View File

@ -95,7 +95,7 @@ func colorize(s interface{}, color int, enabled bool) string {
func levelColor(level string) int {
switch level {
case "debug":
return cGray
return cMagenta
case "info":
return cGreen
case "warn":
@ -109,7 +109,7 @@ func levelColor(level string) int {
func needsQuote(s string) bool {
for i := range s {
if s[i] < 0x20 || s[i] > 0x7e || s[i] == '\\' || s[i] == '"' {
if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' {
return true
}
}

1
log.go
View File

@ -167,6 +167,7 @@ func (l Logger) Output(w io.Writer) Logger {
l2 := New(w)
l2.level = l.level
l2.sample = l.sample
l2.context = make([]byte, len(l.context))
copy(l2.context, l.context)
return l2
}

BIN
pretty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB