gulog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

README

Logging

A simple and lightweight logging package for Go with support for colored output, JSON logs, and file logging.

Installation

go get github.com/vrianta/gulog

Basic Usage

log.Debug("Debug message")
log.Info("Application started")
log.Success("Operation completed")
log.Warn("Something looks wrong")
log.Error("Something failed")

Formatted Messages

log.Info("Listening on port %d", 8080)
log.Error("Failed to connect: %v", err)

Custom Logger

logger := log.New(&log.Config{
    Format: "json",
    File:   "app.log",
})

logger.Info("Server started")

Configuration

Field Description
NoLog Disable console output.
Format text or json.
File Save logs to a file.

Environment Variables

Variable Default
NO_GULOG false
GULOG_FORMAT text
GULOG_LOGFIE (empty)

Output

Text
[2026-07-22 12:30:45] INFO: Server started
JSON
{
    "timestamp": "2026-07-22 12:30:45",
    "level": "INFO",
    "message": "Server started"
}

Documentation

Index

Constants

View Source
const (
	Unknown _type = iota
	DEBUG
	INFO
	WARN
	ERROR
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

Colored log wrappers

func Error

func Error(msg string, args ...any)

func Info

func Info(msg string, args ...any)

func New

func New(_conf *Config) writer

func Success

func Success(msg string, args ...any)

func Wait added in v1.0.1

func Wait()

func Warn

func Warn(msg string, args ...any)

func WriteLog

func WriteLog(messages ...any)

Legacy support

func WriteLogf

func WriteLogf(msg string, args ...any)

Laggacy Support

Types

type Config

type Config struct {
	// Stop the Log Printing in the console useful for production environment
	NoLog bool `env:"NO_GULOG" arg:"no-gulog" default:"false"`
	// it let the user decide how he want to see the log supported formats are only json and plain texts now
	Format string `env:"GULOG_FORMAT" arg:"gulog-format" default:"text"`
	// a file name where user want to store the log, by default it is empty meens user do not want to create logs
	File string `env:"GULOG_LOGFIE" arg:"gulog-logfile" default:""`
}

Jump to

Keyboard shortcuts

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