logger

package module
v0.0.0-...-bd92c43 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 8 Imported by: 0

README

Go-Logger

A lightweight, extensible logging library for Go built on slog. Supports multi-output logging (console + file), colored terminal output via tint, and dynamic log level control.

Go Reference

📍 Installation

go get github.com/VolkHackVH/go-logger

🌟 Features

  • Log level: Log, Debug, Warn, Error
  • Level control: Toggle between DEBUG and ERROR modes at initialization
  • Dual output: Simultaneous logging to console (with colors) and files
  • Structured logging: Compatible with slog.Attr and context values
  • File rotation: Helper function for log file creation
  • Zero-dependency: Only uses standard library + tint for colors

⚡ Example

package main

import (
    "github.com/VolkHackVH/go-logger"
)

func main() {
    /* Enable debug logging (false would show only errors) */
    logger.NewLogger(true, "./Logger/Logger.log")

    logger.Log("Initialized...")
    logger.Debug("Connected to Database...")
    logger.Warn("Detected...")
    err := logger.Error("Connection failed: %v", err) // returns error
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNewLogFile

func CreateNewLogFile(pathAndName ...string) error

func Debug

func Debug(v ...interface{})

func Error

func Error(format string, args ...interface{}) error

func Log

func Log(v ...interface{})

func NewLogger

func NewLogger(onEnabled bool, fileNameAndPath ...string)

func Warn

func Warn(v ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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