logger

package module
v0.0.0-...-1b2502d Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 7 Imported by: 0

README

go-logger

🔐 A lightweight, expressive logging utility for Go projects. Includes color-coded output, log levels, and optional fatal handling.

✨ Features

  • ✅ Log levels: Success, Info, Warning, Error, Fatal
  • 🎨 Color-coded output using emojis and ANSI styles
  • 🛑 Fatal logs terminate the app
  • 🔧 Toggle logging on/off globally

🚀 Installation

go get github.com/AndresGT/go-logger

🧪 Usage

package main

import "github.com/AndresGT/go-logger"

func main() {
    logger.LogSuccess("Servidor iniciado correctamente")
    logger.LogInfo("Escuchando en el puerto %d", 8080)
    logger.LogWarn("Límite de peticiones alcanzado para el cliente %s", "client_123")
    logger.LogError("Error al conectar con la base de datos: %s", "timeout")
    logger.LogFatal("Error crítico: %s", "token inválido")
}

🔧 Configuration

logger.DisableLogs()       // Silencia todos los logs (excepto fatales)
logger.EnableConsoleLogs() // Reactiva la salida por consola

📦 Log Levels

Function Description Terminates Execution
LogSuccess Success message (✔ green)
LogInfo Informational message (ℹ cyan)
LogWarn Warning message (⚠ yellow)
LogError Error message (✖ red)
LogFatal Fatal error (💀 bright red)

📄 License

MIT

🤝 Contributing

Pull requests and suggestions are welcome! If you have ideas to improve the package (like JSON log support, file rotation, or external integrations), feel free to open an issue.

Documentation

Overview

logger/logger.go

Index

Constants

This section is empty.

Variables

View Source
var EnableLogs = true

Functions

func DisableLogs

func DisableLogs()

func EnableConsoleLogs

func EnableConsoleLogs()

func LogError

func LogError(format string, args ...interface{})

func LogFatal

func LogFatal(format string, args ...interface{})

func LogInfo

func LogInfo(format string, args ...interface{})

func LogSuccess

func LogSuccess(format string, args ...interface{})

Funciones públicas de logging

func LogWarn

func LogWarn(format string, args ...interface{})

func RegisterRoute

func RegisterRoute(group *gin.RouterGroup, method string, path string, handler gin.HandlerFunc, protected bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

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