Files
Rafal Jeczalik bd62d61df5 update license / authors
Done with:

  ~ $ find . -type f -name '*.go' -exec prepend -f preamble.txt {} \;

Automate with CI?
2015-02-15 13:44:09 +01:00

55 lines
1005 B
Go

// Copyright (c) 2014-2015 The Notify Authors. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
package notify
import (
"fmt"
"os"
"runtime"
"strings"
)
func stacktrace(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
}
type debug bool
func (d debug) Print(v ...interface{}) {
if d {
fmt.Printf("[D] ")
fmt.Print(v...)
fmt.Printf("\n\n")
}
}
func (d debug) Printf(format string, v ...interface{}) {
if d {
fmt.Printf("[D] ")
fmt.Printf(format, v...)
fmt.Printf("\n\n")
}
}
var dbg = func() debug {
if os.Getenv("NOTIFY_DEBUG") != "" {
return true
}
return false
}()