logger

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 2 Imported by: 0

README

logger

The modular log for log providers

Installation

go get -u github.com/palano/logger

Quick Start

// Config
type ConfigLog struct {
	LevelKey          string
	TimeKey           string
	MessageKey        string
	CallerKey         string
	StacktracerKey    string
	EnableCaller      bool
	EnableStacktracer bool
	EnableFileLog     bool
	FileLog           string
	MaxSize           int
	MaxBackups        int
	MaxAge            int
}
Example for ⚡ Zap

import (
    "github.com/palano/logger"
    "github.com/palano/logger/zap"
)

func main() {
    lc := logger.ConfigLog{}
    log := zap.New(lc)
    log.Info("Example")
    
    log.WithFields(logger.Fields{
        "content": "example",
    }).Info("Example")
}
Example for Logrus

import (
    "github.com/palano/logger"
    "github.com/palano/logger/logrus"
)

func main() {
    lc := logger.ConfigLog{}
    log := logrus.New(lc)
    log.Info("Example")
    
    log.WithFields(logger.Fields{
        "content": "example",
    }).Info("Example")
}
Example for Zerolog

import (
    "github.com/palano/logger"
    "github.com/palano/logger/zerolog"
)

func main() {
    lc := logger.ConfigLog{}
    log := zerolog.New(lc)
    log.Info("Example")
    
    log.WithFields(logger.Fields{
        "content": "example",
    }).Info("Example")
}

Providers

File Log Writer

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceProvider

func ReplaceProvider(logger Logger) func()

Types

type ConfigLog

type ConfigLog struct {
	LevelKey          string
	TimeKey           string
	MessageKey        string
	CallerKey         string
	StacktracerKey    string
	EnableCaller      bool
	EnableStacktracer bool
	EnableFileLog     bool
	FileLog           string
	MaxSize           int
	MaxBackups        int
	MaxAge            int
}

Config log

func CleanConfig

func CleanConfig(cfg ConfigLog) ConfigLog

type Fields

type Fields map[string]interface{}

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Panic(args ...interface{})
	Panicf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	WithFields(keyValues Fields) Logger
}

func NewLogger

func NewLogger() Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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