Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 8, 2022 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/36043c363537f1f219746c1ea42bccf0 to your computer and use it in GitHub Desktop.
Save BetterProgramming/36043c363537f1f219746c1ea42bccf0 to your computer and use it in GitHub Desktop.
func (l *loggingT) setV(pc uintptr) Level {
fn := runtime.FuncForPC(pc)
file, _ := fn.FileLine(pc)
// The file is something like /a/b/c/d.go. We want just the d.
if strings.HasSuffix(file, ".go") {
file = file[:len(file)-3]
}
if slash := strings.LastIndex(file, "/"); slash >= 0 {
file = file[slash+1:]
}
for _, filter := range l.vmodule.filter {
if filter.match(file) {
l.vmap[pc] = filter.level
return filter.level
}
}
l.vmap[pc] = 0
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment