log

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

📝 go-log

Installation

go get github.com/s1m0n21/go-log

Quick start

package main

import (
	logger "github.com/s1m0n21/go-log"
)

func main() {
	// log to console
	log := logger.New("a")
	log.Infof("test")
	
	// set log level dynamic
	_ = logger.SetLevel("*", "error")
	
	// log to file
	// log file max size: 100MiB
	// log file max backups: 5
	// log file max age: 7days
	log = logger.New("b", logger.OptSetLogFile("b.log", 100, 5, 7))
	log.Infof("test")
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLoggerNotExist = xerrors.New("logger does not exist")

Functions

func New

func New(system string, opts ...Option) *zap.SugaredLogger

func SetLevel

func SetLevel(system, level string) error

Types

type Option

type Option func(*config)

func OptLevelFromEnv

func OptLevelFromEnv() Option

func OptSetLevel

func OptSetLevel(lvl string) Option

func OptSetLogFile

func OptSetLogFile(filename string, size, backups, age int) Option

Jump to

Keyboard shortcuts

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