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

Record.CallPC is too short #102

Open
coderwoo opened this issue Aug 16, 2016 · 4 comments
Open

Record.CallPC is too short #102

coderwoo opened this issue Aug 16, 2016 · 4 comments

Comments

@coderwoo
Copy link

// 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(....)
}
@ChrisHines
Copy link
Collaborator

What do you want to do in Info_wrapper that cannot be done by a custom log15.Handler?

@coderwoo
Copy link
Author

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

@coderwoo
Copy link
Author

sorry for my chinglish : )

@decibel
Copy link

decibel commented Jan 20, 2018

I've run into this same kind of problem while using pkg/errors: pkg/errors#129.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants