github.com/haraldrudell/parl@v0.4.176/plog/d.go (about) 1 /* 2 © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package plog 7 8 import ( 9 "os" 10 11 "github.com/haraldrudell/parl/perrors" 12 "github.com/haraldrudell/parl/pruntime" 13 ) 14 15 const pruntimeDframes = 1 16 17 // stderrLogLogger is a shared log.Logger instance for stderr. 18 // - using this for output ensures thread-safety with plog and parl packages 19 var stderrLogLogger = GetLog(os.Stderr) 20 21 // D prints to stderr with code location. Thread-safe. 22 // - D is like parl.D but can be used by packages imported by parl 23 // - D is meant for temporary output intended to be removed before check-in 24 func D(format string, a ...interface{}) { 25 if err := stderrLogLogger.Output(0, 26 pruntime.AppendLocation( 27 Sprintf(format, a...), 28 pruntime.NewCodeLocation(pruntimeDframes), 29 )); err != nil { 30 panic(perrors.ErrorfPF("log.Logger.Output error: %w", err)) 31 } 32 }