Documentation
¶
Overview ¶
Package logecs is a wrapper for the standard log package, providing enhanced structured logging capabilities with support for colors, output to files, and different log levels.
Example usage:
package main
import logecs "github.com/ecsavigne/logecs/log"
func main() {
Logecs := logecs.NewLoggerEcs(logecs.EcsLogger{
Mod: "ModuleName", Color: true,
Path: "output.log", OutPut: true,
})
Logecs.Debugf("Modulo iniciado")
Logecs.Warnf("Warning %s", "Modulo iniciado")
Logecs.Errorf("Error %s", "Modulo iniciado")
Logecs.Infof("Info %s", "Modulo iniciado")
}
Index ¶
Constants ¶
View Source
const ( Unknown = iota Info Error Warn Debug )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EcsLogger ¶
type EcsLogger struct {
Mod string // Name of module of the log, exemple: "NameService"
Color bool // If true, then info, warn and error logs will be colored cyan, yellow and red respectively using ANSI color escape codes
OutPut bool // If true, then the log will be output to stdout
NotStandardPut bool // If true, then the log will be to standard output. If not especified do not output to standard output
LevelMin string
Path string // path to the log file
// contains filtered or unexported fields
}
type InfoLog ¶ added in v1.27.202601240428
type InfoLog struct {
Type TYPE_LOG // "Debug" | "Info" | "Warm" | "Error"
Sub string
Name string // Name of the log ej: "event_service_logs"
Content map[string]any
}
ej: event_service_logs {"tag": "value", .... "tagN": "valueN"}
type Logger ¶
type Logger interface {
// outputs a log message with the given level off info and message.
// example:
//
// Logecs := logecs.NewLoggerEcs(logecs.EcsLogger{
// Mod: "ModuleName", Color: true,
// Path: "output.log", OutPut: true,
// })
//
// Logecs.Warnf("Warning %s", "Module initilized")
Warnf(msg string, args ...any)
// outputs a log message with the given level off error and message.
// example:
//
// Logecs := logecs.NewLoggerEcs(logecs.EcsLogger{
// Mod: "ModuleName", Color: true,
// Path: "output.log", OutPut: true,
// })
//
// Logecs.Errorf("Error %s", "Module initilized")
Errorf(msg string, args ...any)
// outputs a log message with the given level off info and message.
// example:
//
// Logecs := logecs.NewLoggerEcs(logecs.EcsLogger{
// Mod: "ModuleName", Color: true,
// Path: "output.log", OutPut: true,
// })
//
// Logecs.Infof("Info %s", "Module initilized")
Infof(msg string, args ...any)
// outputs a log message with the given level off info and message.
// example:
//
// Logecs := logecs.NewLoggerEcs(logecs.EcsLogger{
// Mod: "ModuleName", Color: true,
// Path: "output.log", OutPut: true,
// })
//
// Logecs.Debugf("Debug %s", "Module initilized")
Debugf(msg string, args ...any)
// func (s *EcsLogger) Sub(mod string) Logger
Sub(module string) Logger
Create(info InfoLog)
}
Logger is a simple interface Logger implementation that outputs to stdout.
func NewLoggerEcs ¶
NewLoggerEcs returns a Logger that outputs to stdout.
Click to show internal directories.
Click to hide internal directories.