diff options
author | Péter Szilágyi <peterke@gmail.com> | 2018-01-02 18:41:47 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-01-02 18:41:47 +0800 |
commit | d2533d0efbb005a826f0950bbd1cb73a82fe90fc (patch) | |
tree | b49ba0918cb79d4e27cf1b6da048add63497f028 /vendor/github.com/rjeczalik/notify/debug.go | |
parent | 3e0113fff4b83c2d398f5d5041ef8b3052c19819 (diff) | |
download | go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.tar go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.tar.gz go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.tar.bz2 go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.tar.lz go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.tar.xz go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.tar.zst go-tangerine-d2533d0efbb005a826f0950bbd1cb73a82fe90fc.zip |
vendor: update github.com/rjeczalik/notify for go1.10 (#15785)
Diffstat (limited to 'vendor/github.com/rjeczalik/notify/debug.go')
-rw-r--r-- | vendor/github.com/rjeczalik/notify/debug.go | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/vendor/github.com/rjeczalik/notify/debug.go b/vendor/github.com/rjeczalik/notify/debug.go index bd9bc468d..2a3eb3370 100644 --- a/vendor/github.com/rjeczalik/notify/debug.go +++ b/vendor/github.com/rjeczalik/notify/debug.go @@ -2,10 +2,52 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build !debug - package notify -func dbgprint(...interface{}) {} +import ( + "log" + "os" + "runtime" + "strings" +) + +var dbgprint func(...interface{}) + +var dbgprintf func(string, ...interface{}) + +var dbgcallstack func(max int) []string -func dbgprintf(string, ...interface{}) {} +func init() { + if _, ok := os.LookupEnv("NOTIFY_DEBUG"); ok || debugTag { + log.SetOutput(os.Stdout) + log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds) + dbgprint = func(v ...interface{}) { + v = append([]interface{}{"[D] "}, v...) + log.Println(v...) + } + dbgprintf = func(format string, v ...interface{}) { + format = "[D] " + format + log.Printf(format, v...) + } + dbgcallstack = func(max int) []string { + pc, stack := make([]uintptr, max), make([]string, 0, max) + runtime.Callers(2, pc) + for _, pc := range pc { + if f := runtime.FuncForPC(pc); f != nil { + fname := f.Name() + idx := strings.LastIndex(fname, string(os.PathSeparator)) + if idx != -1 { + stack = append(stack, fname[idx+1:]) + } else { + stack = append(stack, fname) + } + } + } + return stack + } + return + } + dbgprint = func(v ...interface{}) {} + dbgprintf = func(format string, v ...interface{}) {} + dbgcallstack = func(max int) []string { return nil } +} |