Open coderwoo opened 8 years ago
What do you want to do in Info_wrapper
that cannot be done by a custom log15.Handler
?
I have multi tasks to do, each task is a go routine. I want each log have a task id, something like:
DBUG | 08-16 23:00:55 | wrapper_test.go:hello:17 | taskId:20 | debug, a=100 |
INFO | 08-16 23:00:55 | wrapper_test.go:hello:18 | taskId:10 | waitting | progress:30
I use gls to store the logger interface. I need featch the special logger in Info_wrapper
first.
func Info_wrapper(value interface{}...) {
logger = gls.Get("logger").(log.logger)
logger.Info(....)
}
func InitLogger(taskId int) {
logger = log.New("taskId": taskId)
gls.Set("logger", logger)
// set custom Format and handler here
}
so, do you have any other idea to implement this? Thanks
sorry for my chinglish : )
I've run into this same kind of problem while using pkg/errors: https://github.com/pkg/errors/issues/129.
CallPC should by more large for this situation: