zabbix/templates/entrypoints/internal/bootstrap/logging.go
2026-07-15 17:51:41 +09:00

39 lines
961 B
Go

//go:build windows
package bootstrap
import (
"fmt"
"os"
"time"
)
// LogInfo writes a timestamped informational message to stdout.
func LogInfo(format string, args ...any) {
logMessage(os.Stdout, "info", format, args...)
}
// LogDebug writes a debug message to stdout when DEBUG_MODE=true.
func LogDebug(env Environment, format string, args ...any) {
if env["DEBUG_MODE"] != "true" {
return
}
logMessage(os.Stdout, "debug", format, args...)
}
// LogWarn writes a warning message to stderr.
func LogWarn(format string, args ...any) {
logMessage(os.Stderr, "warning", format, args...)
}
// LogError writes an error message to stderr.
func LogError(format string, args ...any) {
logMessage(os.Stderr, "error", format, args...)
}
func logMessage(file *os.File, level, format string, args ...any) {
timestamp := time.Now().UTC().Format("2006-01-02T15:04:05Z")
fmt.Fprintf(file, "%s [%s]: %s\n", timestamp, level, fmt.Sprintf(format, args...))
}