Documentation
¶
Index ¶
- Constants
- Variables
- func Configure(cfg *Config)
- func DefaultPrefixWidth() int
- func LogLevelName(level Level) string
- func RegisterBootFactory()
- func SetDefaultEnableSourceLocation(flag bool)
- func SetDefaultLevel(lvl Level)
- func SetDefaultPrefixWidth(width int)
- func SetLevel(name string, lvl Level)
- func StringToLogLevelHookFunc(f reflect.Type, t reflect.Type, data any) (any, error)
- type Config
- type Level
- type LevelConfig
- type Log
- type LogFileConf
- type LogServerConfig
- type Module
Constants ¶
View Source
const ModuleId = "machbase.com/neo-logging"
Variables ¶
View Source
var PresetConfigDiscard = Config{ Console: false, Filename: ".", Append: false, DefaultPrefixWidth: 30, DefaultEnableSourceLocation: true, DefaultLevel: "TRACE", }
View Source
var PresetConfigStdout = Config{ Console: false, Filename: "-", Append: true, DefaultPrefixWidth: 30, DefaultEnableSourceLocation: true, DefaultLevel: "TRACE", }
Functions ¶
func DefaultPrefixWidth ¶
func DefaultPrefixWidth() int
func LogLevelName ¶
func RegisterBootFactory ¶
func RegisterBootFactory()
func SetDefaultEnableSourceLocation ¶
func SetDefaultEnableSourceLocation(flag bool)
func SetDefaultLevel ¶
func SetDefaultLevel(lvl Level)
func SetDefaultPrefixWidth ¶
func SetDefaultPrefixWidth(width int)
Types ¶
type Config ¶
type Config struct { Console bool `json:"console" default:"true" help:"enable console output"` Filename string `json:"filename" placeholder:"<path>" help:"log file path"` Append bool `json:"append" help:"append to existing log file"` RotateSchedule string `json:"rotateSchedule" help:"schedule to roate log file"` MaxSize int `json:"maxSize" help:"log file max size in MB"` MaxBackups int `json:"maxBackups" help:"number of backup files"` MaxAge int `json:"maxAge" help:"how many days keep backup files"` Compress bool `json:"compress" placeholder:"true|false" default:"false" help:"compress backup files"` Levels []LevelConfig `json:"levels" hidden:""` UTC bool `json:"utc" help:"log time format in UTC"` DefaultPrefixWidth int `json:"defaultPrefixWidth" default:"20" hidden:""` DefaultEnableSourceLocation bool `json:"defaultEnableSourceLocation" default:"false" hidden:""` DefaultLevel string `json:"defaultLevel" enum:"TRACE,DEBUG,INFO,WARN,ERROR" default:"INFO" help:"TRACE,DEBUG,INFO,WARN,ERROR"` }
type Level ¶
type Level int
func DefaultLevel ¶
func DefaultLevel() Level
func ParseLogLevel ¶
func ParseLogLevelP ¶
func (*Level) UnmarshalJSON ¶
type LevelConfig ¶
type Log ¶
type Log interface { io.Writer TraceEnabled() bool Trace(...any) Tracef(format string, args ...any) DebugEnabled() bool Debug(...any) Debugf(format string, args ...any) InfoEnabled() bool Info(...any) Infof(format string, args ...any) WarnEnabled() bool Warn(...any) Warnf(format string, args ...any) ErrorEnabled() bool Error(...any) Errorf(format string, args ...any) LogEnabled(level Level) bool Log(level Level, m ...any) Logf(level Level, format string, args ...any) LogWithSkipCallstack(lvl Level, skip int, m ...any) LogfWithSkipCallstack(lvl Level, skip int, format string, args ...any) SetLevel(level Level) Level() Level }
func NewLogFile ¶
func NewLogFile(name string, cfg LogFileConf) Log
type LogFileConf ¶
type LogServerConfig ¶
Click to show internal directories.
Click to hide internal directories.