Compare commits
No commits in common. "master" and "v1.0.7" have entirely different histories.
|
@ -10,14 +10,11 @@ import (
|
||||||
|
|
||||||
// LogFormatter is a function type that formats a LogEvent into a string.
|
// LogFormatter is a function type that formats a LogEvent into a string.
|
||||||
// Example:
|
// Example:
|
||||||
//
|
|
||||||
// formatter := func(event LogEvent) string {
|
// formatter := func(event LogEvent) string {
|
||||||
// return fmt.Sprintf("[%s] %s: %v", event.Ts.Format("2006-01-02"), event.Level, event.Data)
|
// return fmt.Sprintf("[%s] %s: %v", event.Ts.Format("2006-01-02"), event.Level, event.Data)
|
||||||
// }
|
// }
|
||||||
type LogFormatter = func(LogEvent) string
|
type LogFormatter = func(LogEvent) string
|
||||||
|
|
||||||
const logTemplate = "[%s] %s : %s - %s\n"
|
|
||||||
|
|
||||||
// format is the default formatter that converts a LogEvent to a string using the default template.
|
// format is the default formatter that converts a LogEvent to a string using the default template.
|
||||||
// It handles both simple values and formatted strings.
|
// It handles both simple values and formatted strings.
|
||||||
// Template: "[timestamp] level : category - data"
|
// Template: "[timestamp] level : category - data"
|
||||||
|
|
3
main.go
3
main.go
|
@ -57,11 +57,9 @@ type LoggersConfig struct {
|
||||||
Appenders map[string]LogAppenderConfig `json:"appenders"`
|
Appenders map[string]LogAppenderConfig `json:"appenders"`
|
||||||
Categories map[string]LogConfig `json:"categories"`
|
Categories map[string]LogConfig `json:"categories"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger represents a logger instance for a specific category.
|
// Logger represents a logger instance for a specific category.
|
||||||
// It maintains the log level and appenders for that category.
|
// It maintains the log level and appenders for that category.
|
||||||
// Example:
|
// Example:
|
||||||
//
|
|
||||||
// logger := GetLogger("mycategory")
|
// logger := GetLogger("mycategory")
|
||||||
// logger.Info("This is an info message")
|
// logger.Info("This is an info message")
|
||||||
// logger.Error("This is an error message")
|
// logger.Error("This is an error message")
|
||||||
|
@ -205,5 +203,4 @@ func RegistAppender(typeName string, appenderCreatCb func(LogAppenderConfig) *Lo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
loggerMap["default"] = defaultLogger
|
loggerMap["default"] = defaultLogger
|
||||||
appenders["console"] = &consoleAppender
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue