Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add phuslu/log #4

Closed
wants to merge 2 commits into from
Closed

feat: add phuslu/log #4

wants to merge 2 commits into from

Conversation

Juneezee
Copy link
Contributor

@Juneezee Juneezee commented Feb 12, 2021

phuslu/log is another logger that claims to be faster [reference] than both uber-go/zap and rs/zerolog.

This pull request includes phuslu/log into the benchmark results. However, currently the logger is not compatible with the test validation because the timestamp field is always enabled, and the duration encoder is string (e.g. 1ms) rather than int (e.g. 1).

Test failure due to timestamp can't be disabled in phuslu/log Fixed by delete(got, "ts") in L437 of main_test.go
--- FAIL: Test/PhusluLog/Enabled/NoContext/Msg (0.00s)
    main_test.go:436: invalid output: mismatch at top level: length mismatch, 3 vs 2; obtained map[string]interface {}{"level":"info", "message":"some string with a somewhat realistic length", "time":1.613121458e+09}; expected map[string]interface {}{"level":"info", "message":"some string with a somewhat realistic length"}
        got: {"time":1613121458,"level":"info","message":"some string with a somewhat realistic length"}
        
        want: {"level":"info","message":"some string with a somewhat realistic length"}

Test failure due to different time and duration encoding being used in phuslu/log
--- FAIL: Test/PhusluLog/Enabled/NoContext/Fields/Times (0.00s)
    main_test.go:436: invalid output: mismatch at ["time"][0]: type mismatch string vs float64; obtained "1970-01-01T07:30:00+07:30"; expected 0
        got: {"time":1613121458,"level":"info","time":["1970-01-01T07:30:00+07:30","1970-01-01T07:30:01+07:30","1970-01-01T07:30:02+07:30","1970-01-01T07:30:03+07:30","1970-01-01T07:30:04+07:30","1970-01-01T07:30:05+07:30","1970-01-01T07:30:06+07:30","1970-01-01T07:30:07+07:30","1970-01-01T07:30:08+07:30","1970-01-01T07:30:09+07:30"],"message":"some string with a somewhat realistic length"}
        
        want: {"level":"info","message":"some string with a somewhat realistic length","time":[0,1,2,3,4,5,6,7,8,9]}

--- FAIL: Test/PhusluLog/Enabled/NoContext/Fields/Durations (0.00s)
    main_test.go:436: invalid output: mismatch at top level: length mismatch, 4 vs 3; obtained map[string]interface {}{"duration":[]interface {}{"0s", "1ms", "2ms", "3ms", "4ms", "5ms", "6ms", "7ms", "8ms", "9ms"}, "level":"info", "message":"some string with a somewhat realistic length", "time":1.613121458e+09}; expected map[string]interface {}{"duration":[]interface {}{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, "level":"info", "message":"some string with a somewhat realistic length"}
        got: {"time":1613121458,"level":"info","duration":["0s","1ms","2ms","3ms","4ms","5ms","6ms","7ms","8ms","9ms"],"message":"some string with a somewhat realistic length"}
        
        want: {"duration":[0,1,2,3,4,5,6,7,8,9],"level":"info","message":"some string with a somewhat realistic length"

phuslu/log outputs the current time if the given TimeFormat is empty, which is causing some of the validations to fail as well.

This pull request is ready when phuslu/log#29 is resolved.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@Juneezee Juneezee closed this Feb 13, 2021
@andersfylling
Copy link

Will this lib be added to your overview?
phuslu/log#29 (comment)

Why are timestamp usually disabled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants