Initial go port of epics
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package ca
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
)
|
||||
|
||||
// calog is the package-level debug logger.
|
||||
// It is active only when the environment variable UOPI_CA_DEBUG is set to a
|
||||
// non-empty value at program startup. All output goes to stderr.
|
||||
var calog *slog.Logger
|
||||
|
||||
func init() {
|
||||
if os.Getenv("UOPI_CA_DEBUG") != "" {
|
||||
calog = slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
|
||||
Level: slog.LevelDebug,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
// dbg emits a DEBUG log if UOPI_CA_DEBUG is set. It is a no-op otherwise.
|
||||
func dbg(msg string, args ...any) {
|
||||
if calog != nil {
|
||||
calog.Debug(msg, args...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user