logger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: AGPL-3.0 Imports: 6 Imported by: 11

README

logger

The logger package serve a centralized module for structured logging.

Log levels

The following log levels are supported sorted from most to least logging debug, info, warn, error.

Usage

This package uses key-value pairs to create logs. Any logging with an uneven amount of keyvals will result in an error. You can pass any number of key-value pairs to adjust these logs to your liking.

package main

import (
    log "github.com/rddl-network/go-utils/logger"
)

func main() {
    logger := log.GetLogger(log.DEBUG)

    logger.Debug("key", "val")
    logger.Info("key", "val")
    logger.Warn("key", "val")
    logger.Error("key", "val")
}

Output:

ts=2024-04-16T08:41:25.002433743Z caller=level.go:71 level=debug key=val
ts=2024-04-16T08:41:25.002487452Z caller=level.go:71 level=info key=val
ts=2024-04-16T08:41:25.002492391Z caller=level.go:71 level=warn key=val
ts=2024-04-16T08:41:25.002495287Z caller=level.go:71 level=error key=val

Documentation

Index

Constants

View Source
const (
	DEBUG = "debug"
	INFO  = "info"
	WARN  = "warn"
	ERROR = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLogger

type AppLogger struct {
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger(logLevel string) AppLogger

func (AppLogger) Debug

func (al AppLogger) Debug(kevals ...interface{})

func (AppLogger) Error

func (al AppLogger) Error(kevals ...interface{})

func (AppLogger) Info

func (al AppLogger) Info(kevals ...interface{})

func (AppLogger) Warn

func (al AppLogger) Warn(kevals ...interface{})

Jump to

Keyboard shortcuts

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