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

[log][survey] Popular logger in Go #26

Closed
10 of 27 tasks
at15 opened this issue Sep 16, 2017 · 5 comments
Closed
10 of 27 tasks

[log][survey] Popular logger in Go #26

at15 opened this issue Sep 16, 2017 · 5 comments

Comments

@at15
Copy link
Member

at15 commented Sep 16, 2017

I remembered there is one or two logging in C++ and/or go that log in a compressed format, and requires extra binary to extra this to a human readable format ... it's nano log, also found the golang version

Goals

  • test performance of current gommon/log (but there is no good field support ....)
  • field support
  • abstract a interface, so user can't rely on implementation detail
  • benchmark
    • how to run go benchmark with memory profile go test -bench=. -benchmem
    • reuse zap's benchmark
    • add multi level to benchmark, set to info level but cal log.Debug, log.Trace very often
  • only log the mutable part like nanolog
    • how to show the full log to stdout when dev ...
  • logging level control
    • control third party library logging level, the library must use gommon/log and expose certain variable
    • must be using golang vendoring properly in order to have package level variable working
  • flush, sync control

Optional Goals

@at15 at15 added the pkg/log label Sep 16, 2017
@at15
Copy link
Member Author

at15 commented Sep 16, 2017

Zap

@at15
Copy link
Member Author

at15 commented Sep 16, 2017

benchmark result on my laptop w/o gommon/log

  • TODO: what does the -8 means in benchmark name
⇒  make bench
go test -bench=. -benchmem
BenchmarkDisabledWithoutFields/Zap-8    	200000000	         7.10 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/Zap.Check-8         	200000000	         7.08 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/Zap.Sugar-8         	100000000	        11.8 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/Zap.SugarFormatting-8         	20000000	        70.8 ns/op	     184 B/op	       7 allocs/op
BenchmarkDisabledWithoutFields/apex/log-8                    	1000000000	         2.35 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/sirupsen/logrus-8             	200000000	         9.36 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/rs/zerolog-8                  	500000000	         3.28 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap-8                    	200000000	         7.15 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.Check-8              	200000000	         6.91 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.Sugar-8              	100000000	        12.2 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.SugarFormatting-8    	20000000	        70.3 ns/op	     184 B/op	       7 allocs/op
BenchmarkDisabledAccumulatedContext/apex/log-8               	2000000000	         1.34 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/sirupsen/logrus-8        	200000000	         9.44 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledAccumulatedContext/rs/zerolog-8             	500000000	         3.27 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAddingFields/Zap-8                          	10000000	       158 ns/op	     768 B/op	       5 allocs/op
BenchmarkDisabledAddingFields/Zap.Check-8                    	200000000	         7.06 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAddingFields/Zap.Sugar-8                    	10000000	       155 ns/op	     344 B/op	      17 allocs/op
BenchmarkDisabledAddingFields/apex/log-8                     	 5000000	       283 ns/op	     934 B/op	      11 allocs/op
BenchmarkDisabledAddingFields/sirupsen/logrus-8              	 3000000	       527 ns/op	    1541 B/op	      13 allocs/op
BenchmarkDisabledAddingFields/rs/zerolog-8                   	30000000	        54.3 ns/op	     128 B/op	       4 allocs/op
BenchmarkWithoutFields/Zap-8                                 	10000000	       169 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.Check-8                           	10000000	       167 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.CheckSampled-8                    	30000000	        40.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.Sugar-8                           	10000000	       214 ns/op	      80 B/op	       2 allocs/op
BenchmarkWithoutFields/Zap.SugarFormatting-8                 	  300000	      3774 ns/op	    2069 B/op	      59 allocs/op
BenchmarkWithoutFields/apex/log-8                            	 1000000	      2899 ns/op	     584 B/op	      11 allocs/op
BenchmarkWithoutFields/go-kit/kit/log-8                      	 5000000	       351 ns/op	     656 B/op	      13 allocs/op
BenchmarkWithoutFields/inconshreveable/log15-8               	  500000	      5673 ns/op	    1592 B/op	      26 allocs/op
BenchmarkWithoutFields/sirupsen/logrus-8                     	 2000000	       874 ns/op	    1507 B/op	      27 allocs/op
BenchmarkWithoutFields/go.pedge.io/lion-8                    	 3000000	       548 ns/op	    1225 B/op	      10 allocs/op
BenchmarkWithoutFields/stdlib.Println-8                      	 5000000	       387 ns/op	      80 B/op	       2 allocs/op
BenchmarkWithoutFields/stdlib.Printf-8                       	  500000	      3316 ns/op	    2058 B/op	      59 allocs/op
BenchmarkWithoutFields/rs/zerolog-8                          	20000000	       112 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/rs/zerolog.Formatting-8               	  500000	      3453 ns/op	    2059 B/op	      59 allocs/op
BenchmarkWithoutFields/rs/zerolog.Check-8                    	20000000	       112 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap-8                            	10000000	       178 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.Check-8                      	10000000	       175 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.CheckSampled-8               	30000000	        39.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.Sugar-8                      	10000000	       223 ns/op	      80 B/op	       2 allocs/op
BenchmarkAccumulatedContext/Zap.SugarFormatting-8            	  300000	      3796 ns/op	    2078 B/op	      59 allocs/op
BenchmarkAccumulatedContext/apex/log-8                       	   50000	     29861 ns/op	    6646 B/op	     115 allocs/op
BenchmarkAccumulatedContext/go-kit/kit/log-8                 	  200000	      6951 ns/op	    6803 B/op	     115 allocs/op
BenchmarkAccumulatedContext/inconshreveable/log15-8          	  100000	     21291 ns/op	    3800 B/op	      79 allocs/op
BenchmarkAccumulatedContext/sirupsen/logrus-8                	  200000	      8258 ns/op	   12615 B/op	     130 allocs/op
BenchmarkAccumulatedContext/go.pedge.io/lion-8               	 1000000	      2167 ns/op	    5870 B/op	      38 allocs/op
BenchmarkAccumulatedContext/rs/zerolog-8                     	20000000	       117 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/rs/zerolog.Check-8               	20000000	       117 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/rs/zerolog.Formatting-8          	  500000	      3465 ns/op	    2060 B/op	      59 allocs/op
BenchmarkAddingFields/Zap-8                                  	 1000000	      1318 ns/op	     771 B/op	       5 allocs/op
BenchmarkAddingFields/Zap.Check-8                            	 1000000	      1315 ns/op	     771 B/op	       5 allocs/op
BenchmarkAddingFields/Zap.CheckSampled-8                     	10000000	       170 ns/op	      87 B/op	       0 allocs/op
BenchmarkAddingFields/Zap.Sugar-8                            	 1000000	      1626 ns/op	    1729 B/op	      21 allocs/op
BenchmarkAddingFields/apex/log-8                             	   50000	     31402 ns/op	    7584 B/op	     126 allocs/op
BenchmarkAddingFields/go-kit/kit/log-8                       	  200000	      6887 ns/op	    6634 B/op	     126 allocs/op
BenchmarkAddingFields/inconshreveable/log15-8                	   50000	     26561 ns/op	    7703 B/op	     149 allocs/op
BenchmarkAddingFields/sirupsen/logrus-8                      	  200000	      8891 ns/op	   14155 B/op	     142 allocs/op
BenchmarkAddingFields/go.pedge.io/lion-8                     	  200000	      6261 ns/op	    9324 B/op	     110 allocs/op
BenchmarkAddingFields/rs/zerolog-8                           	  200000	      6170 ns/op	    8564 B/op	      90 allocs/op
BenchmarkAddingFields/rs/zerolog.Check-8                     	  200000	      6157 ns/op	    8564 B/op	      90 allocs/op
PASS
ok  	go.uber.org/zap/benchmarks	114.052s

@at15
Copy link
Member Author

at15 commented Sep 16, 2017

Added gommon in at15/zap@a975bfe, but there is no WithField in gommon, so didn't benchmark AccumulatedContext and AddingField, also even without any field ... gommon always have a pkg field, and we are not using JSON Formatter, just plain text formatter (w/ color?)

⇒  make bench
go test -bench=. -benchmem
BenchmarkDisabledWithoutFields/Zap-8    	200000000	         7.11 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/Zap.Check-8         	200000000	         7.63 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/Zap.Sugar-8         	100000000	        11.7 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/Zap.SugarFormatting-8         	20000000	        71.9 ns/op	     184 B/op	       7 allocs/op
BenchmarkDisabledWithoutFields/apex/log-8                    	1000000000	         4.65 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/sirupsen/logrus-8             	200000000	         9.88 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/gommon/log-8                  	200000000	         9.57 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/rs/zerolog-8                  	500000000	         3.28 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap-8                    	200000000	         7.07 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.Check-8              	200000000	         7.19 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.Sugar-8              	100000000	        11.7 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.SugarFormatting-8    	20000000	        71.7 ns/op	     184 B/op	       7 allocs/op
BenchmarkDisabledAccumulatedContext/apex/log-8               	2000000000	         1.32 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/sirupsen/logrus-8        	200000000	         9.66 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledAccumulatedContext/rs/zerolog-8             	500000000	         3.28 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAddingFields/Zap-8                          	10000000	       163 ns/op	     768 B/op	       5 allocs/op
BenchmarkDisabledAddingFields/Zap.Check-8                    	200000000	         7.17 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAddingFields/Zap.Sugar-8                    	10000000	       161 ns/op	     344 B/op	      17 allocs/op
BenchmarkDisabledAddingFields/apex/log-8                     	 5000000	       289 ns/op	     934 B/op	      11 allocs/op
BenchmarkDisabledAddingFields/sirupsen/logrus-8              	 3000000	       533 ns/op	    1541 B/op	      13 allocs/op
BenchmarkDisabledAddingFields/rs/zerolog-8                   	30000000	        55.7 ns/op	     128 B/op	       4 allocs/op
BenchmarkWithoutFields/Zap-8                                 	10000000	       173 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.Check-8                           	10000000	       157 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.CheckSampled-8                    	50000000	        39.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.Sugar-8                           	10000000	       220 ns/op	      80 B/op	       2 allocs/op
BenchmarkWithoutFields/Zap.SugarFormatting-8                 	  500000	      3794 ns/op	    2069 B/op	      59 allocs/op
BenchmarkWithoutFields/apex/log-8                            	 1000000	      2452 ns/op	     584 B/op	      11 allocs/op
BenchmarkWithoutFields/go-kit/kit/log-8                      	 5000000	       359 ns/op	     656 B/op	      13 allocs/op
BenchmarkWithoutFields/inconshreveable/log15-8               	  500000	      5463 ns/op	    1592 B/op	      26 allocs/op
BenchmarkWithoutFields/sirupsen/logrus-8                     	 2000000	       891 ns/op	    1507 B/op	      27 allocs/op
BenchmarkWithoutFields/gommon/log-8                          	10000000	       218 ns/op	     488 B/op	       6 allocs/op
BenchmarkWithoutFields/go.pedge.io/lion-8                    	 3000000	       561 ns/op	    1225 B/op	      10 allocs/op
BenchmarkWithoutFields/stdlib.Println-8                      	 5000000	       397 ns/op	      80 B/op	       2 allocs/op
BenchmarkWithoutFields/stdlib.Printf-8                       	  500000	      3371 ns/op	    2058 B/op	      59 allocs/op
BenchmarkWithoutFields/rs/zerolog-8                          	20000000	       112 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/rs/zerolog.Formatting-8               	  500000	      3525 ns/op	    2060 B/op	      59 allocs/op
BenchmarkWithoutFields/rs/zerolog.Check-8                    	20000000	       113 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap-8                            	10000000	       182 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.Check-8                      	10000000	       182 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.CheckSampled-8               	30000000	        41.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.Sugar-8                      	10000000	       219 ns/op	      80 B/op	       2 allocs/op
BenchmarkAccumulatedContext/Zap.SugarFormatting-8            	  300000	      3812 ns/op	    2078 B/op	      59 allocs/op
BenchmarkAccumulatedContext/apex/log-8                       	   50000	     30764 ns/op	    6648 B/op	     115 allocs/op
BenchmarkAccumulatedContext/go-kit/kit/log-8                 	  200000	      7060 ns/op	    6802 B/op	     115 allocs/op
BenchmarkAccumulatedContext/inconshreveable/log15-8          	  100000	     18306 ns/op	    3799 B/op	      79 allocs/op
BenchmarkAccumulatedContext/sirupsen/logrus-8                	  200000	      8382 ns/op	   12615 B/op	     130 allocs/op
BenchmarkAccumulatedContext/go.pedge.io/lion-8               	 1000000	      2220 ns/op	    5870 B/op	      38 allocs/op
BenchmarkAccumulatedContext/rs/zerolog-8                     	20000000	       117 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/rs/zerolog.Check-8               	20000000	       117 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/rs/zerolog.Formatting-8          	  500000	      3525 ns/op	    2060 B/op	      59 allocs/op
BenchmarkAddingFields/Zap-8                                  	 1000000	      1299 ns/op	     771 B/op	       5 allocs/op
BenchmarkAddingFields/Zap.Check-8                            	 1000000	      1339 ns/op	     771 B/op	       5 allocs/op
BenchmarkAddingFields/Zap.CheckSampled-8                     	10000000	       173 ns/op	      88 B/op	       0 allocs/op
BenchmarkAddingFields/Zap.Sugar-8                            	 1000000	      1630 ns/op	    1729 B/op	      21 allocs/op
BenchmarkAddingFields/apex/log-8                             	   30000	     47915 ns/op	    7582 B/op	     126 allocs/op
BenchmarkAddingFields/go-kit/kit/log-8                       	  200000	      6946 ns/op	    6635 B/op	     126 allocs/op
BenchmarkAddingFields/inconshreveable/log15-8                	   50000	     34949 ns/op	    7705 B/op	     149 allocs/op
BenchmarkAddingFields/sirupsen/logrus-8                      	  200000	      9031 ns/op	   14155 B/op	     142 allocs/op
BenchmarkAddingFields/go.pedge.io/lion-8                     	  200000	      6428 ns/op	    9324 B/op	     110 allocs/op
BenchmarkAddingFields/rs/zerolog-8                           	  200000	      6327 ns/op	    8564 B/op	      90 allocs/op
BenchmarkAddingFields/rs/zerolog.Check-8                     	  200000	      6180 ns/op	    8564 B/op	      90 allocs/op
PASS
ok  	go.uber.org/zap/benchmarks	124.837s

at15 added a commit to at15/zap that referenced this issue Sep 16, 2017
- field does not have good support in gommon, so it is not tested
- dyweb/gommon#26
@at15 at15 mentioned this issue Sep 16, 2017
5 tasks
@at15
Copy link
Member Author

at15 commented Sep 16, 2017

zerolog seems to have its own json encoder .... https://github.com/rs/zerolog/tree/master/internal/json which use direct copy instead of encode when data is not ", \ etc.

@at15
Copy link
Member Author

at15 commented Sep 18, 2017

after introducing DeleteField

  • nothing changed .... but how can there be no byte allocate in zap and zero log ... pool?

benchmarkwithoutfields bytesperop

BenchmarkDisabledWithoutFields/Zap-8    	200000000	         7.36 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/Zap.Check-8         	200000000	         7.30 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/Zap.Sugar-8         	100000000	        13.2 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/Zap.SugarFormatting-8         	20000000	        78.2 ns/op	     184 B/op	       7 allocs/op
BenchmarkDisabledWithoutFields/apex/log-8                    	1000000000	         2.47 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledWithoutFields/sirupsen/logrus-8             	100000000	        10.2 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/gommon/log-8                  	100000000	        10.1 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledWithoutFields/rs/zerolog-8                  	500000000	         3.38 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap-8                    	200000000	         7.48 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.Check-8              	200000000	         7.35 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.Sugar-8              	100000000	        13.4 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledAccumulatedContext/Zap.SugarFormatting-8    	20000000	        93.3 ns/op	     184 B/op	       7 allocs/op
BenchmarkDisabledAccumulatedContext/apex/log-8               	2000000000	         1.39 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAccumulatedContext/sirupsen/logrus-8        	100000000	        11.6 ns/op	      16 B/op	       1 allocs/op
BenchmarkDisabledAccumulatedContext/rs/zerolog-8             	500000000	         3.42 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAddingFields/Zap-8                          	10000000	       191 ns/op	     768 B/op	       5 allocs/op
BenchmarkDisabledAddingFields/Zap.Check-8                    	200000000	         7.40 ns/op	       0 B/op	       0 allocs/op
BenchmarkDisabledAddingFields/Zap.Sugar-8                    	10000000	       176 ns/op	     344 B/op	      17 allocs/op
BenchmarkDisabledAddingFields/apex/log-8                     	 5000000	       312 ns/op	     934 B/op	      11 allocs/op
BenchmarkDisabledAddingFields/sirupsen/logrus-8              	 3000000	       586 ns/op	    1541 B/op	      13 allocs/op
BenchmarkDisabledAddingFields/rs/zerolog-8                   	20000000	        64.1 ns/op	     128 B/op	       4 allocs/op
BenchmarkWithoutFields/Zap-8                                 	10000000	       163 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.Check-8                           	10000000	       173 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.CheckSampled-8                    	30000000	        40.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/Zap.Sugar-8                           	10000000	       232 ns/op	      80 B/op	       2 allocs/op
BenchmarkWithoutFields/Zap.SugarFormatting-8                 	  300000	      4101 ns/op	    2069 B/op	      59 allocs/op
BenchmarkWithoutFields/apex/log-8                            	 1000000	      3144 ns/op	     584 B/op	      11 allocs/op
BenchmarkWithoutFields/go-kit/kit/log-8                      	 5000000	       387 ns/op	     656 B/op	      13 allocs/op
BenchmarkWithoutFields/inconshreveable/log15-8               	  300000	      4946 ns/op	    1592 B/op	      26 allocs/op
BenchmarkWithoutFields/sirupsen/logrus-8                     	 2000000	      1003 ns/op	    1507 B/op	      27 allocs/op
BenchmarkWithoutFields/gommon/log-8                          	10000000	       218 ns/op	     488 B/op	       6 allocs/op
BenchmarkWithoutFields/gommon/log-pkg-8                      	 5000000	       243 ns/op	     488 B/op	       6 allocs/op
BenchmarkWithoutFields/go.pedge.io/lion-8                    	 2000000	       612 ns/op	    1225 B/op	      10 allocs/op
BenchmarkWithoutFields/stdlib.Println-8                      	 3000000	       408 ns/op	      80 B/op	       2 allocs/op
BenchmarkWithoutFields/stdlib.Printf-8                       	  500000	      3598 ns/op	    2058 B/op	      59 allocs/op
BenchmarkWithoutFields/rs/zerolog-8                          	20000000	       115 ns/op	       0 B/op	       0 allocs/op
BenchmarkWithoutFields/rs/zerolog.Formatting-8               	  300000	      3726 ns/op	    2059 B/op	      59 allocs/op
BenchmarkWithoutFields/rs/zerolog.Check-8                    	20000000	       116 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap-8                            	10000000	       195 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.Check-8                      	10000000	       182 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.CheckSampled-8               	30000000	        42.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/Zap.Sugar-8                      	 5000000	       238 ns/op	      80 B/op	       2 allocs/op
BenchmarkAccumulatedContext/Zap.SugarFormatting-8            	  300000	      4114 ns/op	    2078 B/op	      59 allocs/op
BenchmarkAccumulatedContext/apex/log-8                       	   50000	     30380 ns/op	    6648 B/op	     115 allocs/op
BenchmarkAccumulatedContext/go-kit/kit/log-8                 	  200000	      7704 ns/op	    6803 B/op	     115 allocs/op
BenchmarkAccumulatedContext/inconshreveable/log15-8          	  100000	     19187 ns/op	    3800 B/op	      79 allocs/op
BenchmarkAccumulatedContext/sirupsen/logrus-8                	  200000	      9156 ns/op	   12614 B/op	     130 allocs/op
BenchmarkAccumulatedContext/go.pedge.io/lion-8               	  500000	      2518 ns/op	    5870 B/op	      38 allocs/op
BenchmarkAccumulatedContext/rs/zerolog-8                     	10000000	       126 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/rs/zerolog.Check-8               	10000000	       129 ns/op	       0 B/op	       0 allocs/op
BenchmarkAccumulatedContext/rs/zerolog.Formatting-8          	  300000	      4222 ns/op	    2060 B/op	      59 allocs/op
BenchmarkAddingFields/Zap-8                                  	 1000000	      1435 ns/op	     771 B/op	       5 allocs/op
BenchmarkAddingFields/Zap.Check-8                            	 1000000	      1435 ns/op	     771 B/op	       5 allocs/op
BenchmarkAddingFields/Zap.CheckSampled-8                     	10000000	       186 ns/op	      88 B/op	       0 allocs/op
BenchmarkAddingFields/Zap.Sugar-8                            	 1000000	      1764 ns/op	    1728 B/op	      21 allocs/op
BenchmarkAddingFields/apex/log-8                             	   50000	     31628 ns/op	    7587 B/op	     126 allocs/op
BenchmarkAddingFields/go-kit/kit/log-8                       	  200000	      7471 ns/op	    6636 B/op	     126 allocs/op
BenchmarkAddingFields/inconshreveable/log15-8                	   50000	     29476 ns/op	    7704 B/op	     149 allocs/op
BenchmarkAddingFields/sirupsen/logrus-8                      	  200000	     10269 ns/op	   14155 B/op	     142 allocs/op
BenchmarkAddingFields/go.pedge.io/lion-8                     	  200000	      7444 ns/op	    9324 B/op	     110 allocs/op
BenchmarkAddingFields/rs/zerolog-8                           	  200000	      6681 ns/op	    8564 B/op	      90 allocs/op
BenchmarkAddingFields/rs/zerolog.Check-8                     	  200000	      8865 ns/op	    8564 B/op	      90 allocs/op
PASS

at15 referenced this issue in at15/ghutil Dec 17, 2017
- obtained from https://github.com/avelino/awesome-go#logging
- most of them are not very popular, only the few I have already know.
  - logrus, zap, glog, log15, zerolog, apex/log
at15 added a commit that referenced this issue Dec 17, 2017
- logrus is same as old gommon/log
- zap and zerolog for performance
- apex-log, for its handler
- go-kit and log15, it seems go-kit log is inspired by log15 [The Hunt for a Logger
Interface](http://go-talks.appspot.com/github.com/ChrisHines/talks/structured-logging/structured-logging.slide#1)
- nanolog is very special, might not be used by common library
- heap and priority_queue comes in because I was preparing for
interview at that time I suppose, around Sep. maybe ...
at15 added a commit that referenced this issue Dec 20, 2017
- gommon/log v1 is modeled after it
  - `AddField` updates in place and is never actually used
- entry represent a log message, its `log` method has non pointer
receiver to avoid race condition, because it updates Time, Message etc.
- it has hooks, and use mutex to lock the global logger when fire
- use buffer pool for bytes.Buffer
- use pool for Entry as well
at15 added a commit that referenced this issue Dec 20, 2017
- just a logger struct for everything, use mutex and pointer receiver
  - it does not have concept of entry like logrus
  - a slice as buffer (for all the log)
  - default log to stderr, `std` is the interal default logger where all `log.Printf` goes
- support line number, release lock when obtain it via `runtime.Caller`
at15 added a commit that referenced this issue Dec 20, 2017
- user create field (context) by using factory method like `String`, which is a
struct contains key, value and type of the value
- when log, i.e. calling `Debug("this is msg", zap.String("foo",
"bar"))`, `Check` is called, which calls `check` and then calls
`Core.Check`, if requirements like level and sample are met, core add
itself to the returned `CheckedEntry`
  - then `CheckedEntry.Write` is called, which loops all the cores and
call `Core.Write(entry, fields)`
  - `Core.Write` calls encoder and write to out (`WriteSyncer`)
- when encoding, field has a `AddTo` method which is based on the
type stored in the field struct when create, then for int calls `buffer.AddInt`,
which calls `strconv.AppendInt`, it is zero allocation compared with
`fmt.Sprintf`
- for out, there seems to be no lock ... guess just rely on stderr and os.File directly
- overall, the implementation is much more complex than stdlib and logrus,
it ask user to specify type of the field in order to avoid using reflection (and be type safe), this is mainly for field though
  - [ ] TODO: actually we can use syntax sugar to wrap those for user
automatically, though I don't know how to keep the comment in original
code, unless we are using regexp to replace instead of traversing AST
at15 added a commit that referenced this issue Dec 22, 2017
- #26
- checked code for `fmt.Printf`, the real logic is in `printArg(arg
interface{}, verb rune)`, which would print simple types like `int`,
`[]byte` directly, though there are many indirection and goes to
`strconv` eventually. for other types (i.e. type MyInt int), reflection
is needed, `printValue(value reflect.Value, verb rune, depth int)`
- but `Printf` supports formatting like `%0.2f`, I don't remember how
zap would handle that, let user call `fmt.Sprintf` for message maybe?
at15 added a commit that referenced this issue Dec 22, 2017
- focus on a small interface, just `Log(keyvals ...interface{})`
- level is not built in, need a wrapper to allow filter by level
- the slide talks a lot about std log and log15's design, which is not
making good use of interface
- it has a adapter for std log, by using regexp to extract info
at15 added a commit that referenced this issue Dec 22, 2017
- it use lock in handler implementations, for logging to stdout/err, I
think the reason the lock is needed is they call fmt.Fprintf
multiple times (for the message and fields) for a single log entry
- the overall process is entry.Debug -> Logger.log ->
Handler.HandleLog(*Entry) -> write to ouput (i.e.
fmt.Fprintf(io.Writer))
- it's good they didn't put Output inside logger, als othe HandlerFunc
part like `net/http`, though I still didn't know why it's using value
instead of pointer receiver #30
at15 added a commit that referenced this issue Dec 22, 2017
- it has interesting features like LOG_IF, LOG_EVERY
- most stuff are squished into one `glog.go` file
- the cpp version has more features, and the code is a little bit hard
to read due to using automake to generate header file (h.in)
at15 added a commit that referenced this issue Dec 22, 2017
- detail xml config, filter by level, file, function (require calling runtime,
expensive)
- many small files, some just have one interface (quite java style ...)
- created back in 2011 ...
at15 added a commit that referenced this issue Dec 22, 2017
- add zerolog, it has custom json encoder, didn't look at the code
carefully, read it before, more unfriendly than zap
- add log4j, lazy evaluation is achieved using Java-8 lambda, similar
is done in log15 by passing function and reflect
- add nanolog, kind of a like a small database ... reminds me of old
days writing xephon-k's storage, calling `binary` package, no context
and level support though, like std log w/ smaller disk usage
- add complexity part for each library
- time to write the design doc for new logv2
@at15 at15 changed the title [log] Survey for high performance logger [log][survey] Popular logger in Go Dec 23, 2017
at15 added a commit that referenced this issue Dec 25, 2017
- **log4j does not have tree**, it's flat, using string as identifier (a
map of loggers), Solr simply split it by dot because class name is used
as logger name, the tree is built in front end
- all the instances of a class share same logger, because it is `public
static final Logger log = LoggerFactory.getLogger(MyClass.class)`
@at15 at15 added this to In progress in log Dec 27, 2017
@at15 at15 closed this as completed in #28 Dec 28, 2017
log automation moved this from In progress to Done Dec 28, 2017
at15 added a commit that referenced this issue Dec 28, 2017
[Partial] Log v2 switch to handler and introduce hierarchy

- detailed survey (include Solr's) #26 
- introduced `Identity`, get identity using runtime #32 , tried to form a tree  hierarchy #33 
- using a handler style, eliminate `Entry` and `Formatter`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
log
  
Done
Development

No branches or pull requests

1 participant