tiny-go-log

command module
v0.0.0-...-bb2ffd7 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 8 Imported by: 0

README

tiny-go-log

A tiny conveniently setup go rolling logger powered by zerolog and lumberjack

Usage

package main

import (
    "github.com/gugabfigueiredo/tiny-go-log"
)

func main() {
    
	// create new logger from local config.go struct
	logger := log.New(&log.Config{
		Context: "my-app",
		// Enable console logging
		ConsoleLoggingEnabled: true,
		// EncodeLogsAsJson makes the log framework log JSON
		EncodeLogsAsJson: true,
		// FileLoggingEnabled makes the framework log to a file
		// the fields below can be skipped if this value is false!
		FileLoggingEnabled: true,
		// Directory to log to when file logging is enabled
		Directory: "/var/log/my-app",
		// Filename is the name of the logfile which will be placed inside the directory
		Filename: "my-app",
		// MaxSize the max size in MB of the logfile before it's rolled
		MaxSize: 10,
		// MaxBackups the max number of rolled files to keep
		MaxBackups: 3,
		// MaxAge the max age in days to keep a logfile
		MaxAge: 2,
    })
	
	logger.I("Hello World")
}

expected output:

{"level":"info","time":"2020-05-01T00:00:00Z","message":"Hello World","context":"my-app"}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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