clustvirt/lib/log/logs.go
Matthew Stobbs ffca8c3970 done migrating host module to libvirtxml
- need to add accessor methods
- eventually will move the VMList to the local guest module
2024-03-21 11:15:23 -06:00

31 lines
1.2 KiB
Go

// Package logs provides a central location for ClustVirt logging, wrapping a Zerolog
// instance to do the job.
// This will standarize logging throughout ClustVirt, and make it easier to debug
// issues.
// The default is to log to Stderr
// TODO: enable logging to syslog through configuration
package log
import (
"os"
"github.com/rs/zerolog"
)
var defaultLogger zerolog.Logger
func init() {
defaultLogger = zerolog.New(zerolog.ConsoleWriter{
Out: os.Stderr,
TimeFormat: zerolog.TimeFormatUnix,
})
}
func Trace(method string) *zerolog.Event { return defaultLogger.Trace().Str("method", method) }
func Debug(method string) *zerolog.Event { return defaultLogger.Debug().Str("method", method) }
func Info(method string) *zerolog.Event { return defaultLogger.Info().Str("method", method) }
func Warn(method string) *zerolog.Event { return defaultLogger.Warn().Str("method", method) }
func Error(method string) *zerolog.Event { return defaultLogger.Error().Str("method", method) }
func Fatal(method string) *zerolog.Event { return defaultLogger.Fatal().Str("method", method) }
func Panic(method string) *zerolog.Event { return defaultLogger.Panic().Str("method", method) }