log15
log15 copied to clipboard
Record.CallPC is too short
// A Record is what a Logger asks its handler to write
type Record struct {
Time time.Time
Lvl Lvl
Msg string
Ctx []interface{}
CallPC [1]uintptr
KeyNames RecordKeyNames
}
CallPC should by more large for this situation:
import (
log "gopkg.in/inconshreveable/log15.v2"
)
func Info_wrapper(value interface{}...) {
// do something here
log.Info(....)
}
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.