You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[log][generator][go] Generate file line number for logging to avoid calling runtime #43
Existing go logging library all use runtime API to get caller when log file line number, which is expensive (we used to that as well #7). It's possible we parse files and add file line number before compile
There are essentially two ways (I can think of ...)
In place update special symbol like __FILE__
use a __FILE__ syntax like in script language (python __file__) or C Marco, and using things like go generate with build flag, user need to explicit specify the special for all the logging call
// Code generated by gommon from foo.go DO NOT EDIT.// +build gommon_log_linepackage foo
varlog=logutil.NewPackageLogger()
funcbar() {
log.DebugFLine("github.com/at15/test/foo.go:10:32", "number of bugs %d", len(bugs))
}
changed the title [-][log][generator][go] Compile time file line number generation[/-][+][log][generator][go] Compile time file line number for logging[/+]on Feb 4, 2018
changed the title [-][log][generator][go] Compile time file line number for logging[/-][+][log][generator][go] Generate file line number for logging to avoid calling runtime[/+]on Feb 4, 2018
Activity
[-][log][generator][go] Compile time file line number generation[/-][+][log][generator][go] Compile time file line number for logging[/+][-][log][generator][go] Compile time file line number for logging[/-][+][log][generator][go] Generate file line number for logging to avoid calling runtime[/+]Merge pull request #42 from dyweb/log/v2.0.2
at15 commentedon Feb 5, 2018
I should implement logger using
runtimefirst, also clean up things like fields before dig into this ...[log] Show source line using `runtime` #43
halink0803 commentedon Feb 26, 2018
@at15 I saw this featured was merged, can you provide a short instruction on how to use this? Thank you.
at15 commentedon Feb 26, 2018
@halink0803 the merged one is using
runtimelibrary, not generating line number at compile time like C (so it still has the overhead like most other logging libraries), an example can be found here https://github.com/dyweb/gommon/blob/master/log/_examples/simple/main.go