Files
versitygw/tests/rest_scripts/logger/logging.go
Ben McClelland 97cc6bf23b chore: run go modernize tool
This is a fixup of the codebase using:
go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./...

This has no bahvior changes, and only updates safe changes for
modern go features.
2026-03-10 09:47:37 -07:00

29 lines
494 B
Go

package logger
import (
"log"
"os"
)
var Debug *bool
var LogFile *string
func PrintDebug(format string, args ...any) {
if *Debug {
if *LogFile != "" {
logFile, err := os.OpenFile(*LogFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Fatalf("Error opening logfile: %v", err)
}
defer logFile.Close()
log.SetOutput(logFile)
}
log.Printf(format, args...)
}
}
func LogFatal(format string, args ...any) {
PrintDebug(format, args...)
os.Exit(1)
}