github.com/julianthome/gore@v0.0.0-20231109011145-b3a6bbe6fe55/debug.go (about)

     1  //go:build debug
     2  // +build debug
     3  
     4  package gore
     5  
     6  import (
     7  	"fmt"
     8  	"os"
     9  	"path/filepath"
    10  	"runtime"
    11  )
    12  
    13  func debugf(format string, args ...any) {
    14  	_, file, line, ok := runtime.Caller(1)
    15  
    16  	if ok {
    17  		format = fmt.Sprintf("%s:%d %s", filepath.Base(file), line, format)
    18  	}
    19  
    20  	fmt.Fprintf(os.Stderr, format+"\n", args...)
    21  }