log

package
v1.27.202601291315 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

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
}

func (*EcsLogger) Create added in v1.27.202601240428

func (s *EcsLogger) Create(info InfoLog)

func (*EcsLogger) Debugf

func (s *EcsLogger) Debugf(msg string, args ...any)

func (*EcsLogger) Errorf

func (s *EcsLogger) Errorf(msg string, args ...any)

func (*EcsLogger) Infof

func (s *EcsLogger) Infof(msg string, args ...any)

func (*EcsLogger) Sub

func (s *EcsLogger) Sub(mod string) Logger

func (*EcsLogger) Warnf

func (s *EcsLogger) Warnf(msg string, args ...any)

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

func NewLoggerEcs(l EcsLogger) Logger

NewLoggerEcs returns a Logger that outputs to stdout.

type TYPE_LOG added in v1.27.202601240428

type TYPE_LOG int

func (TYPE_LOG) ENUM added in v1.27.202601240428

func (t TYPE_LOG) ENUM() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL