glog: how to add wrapper to log sinks ? Maybe move glog/internal/logsync out of internal ?

54 views
Skip to first unread message

Jan

unread,
May 22, 2023, 1:30:11 AM5/22/23
to golang-nuts
hi,

I want to add a prefix to the glog lines based on certain conditions of my program.

Browsing the glog code I found an example that seems exactly for that in package `glog/internal/logsync`:


 But unfortunately it is marked as `internal`, so not accessible. Any chances it could be made public ?

Or any suggestions on how to easily achieve the same result ?

Thanks!
Jan

ps.: I looked at other logging libraries, but I do require (use often) fine-grained level control of logging per file, like glog, and the libraries I checked (zap, logrus, zerolog, apex) don't seem to offer that.

Jan

unread,
May 22, 2023, 2:22:41 AM5/22/23
to golang-nuts
A bit more of search and I found klog, which conveniently already provides SetLogFilter, which resolves the issue.

cheers
Jan

ps.: s/logsync/logsink -- sorry.



Reply all
Reply to author
Forward
0 new messages