logging

package module
v0.0.0-...-ca9dbd9 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 7 Imported by: 0

README

lklogger

Create loggerService.go first

package loggerService

import (
	logging "github.com/Lonka/lklogger"
	"go.uber.org/zap/zapcore"
)

var (
	Service logging.LoggerBase
	API     logging.LoggerBase
)

func Serve() {
	newLogger(&Service, "Service")
	newLogger(&API, "API")
}

func newLogger(log *logging.LoggerBase, serviceName string) {
	log.Logger = logging.NewLogger("", zapcore.InfoLevel, 100, 3, 7, true, serviceName)
	log.ServiceName = serviceName
}

Use it

func main(){
    loggerService.Serve()
	loggerService.Service.Info("Try it")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetField

func GetField(key, value string) zapcore.Field

func NewLogger

func NewLogger(filePath string, level zapcore.Level, maxSize int, maxBackups int, maxAge int, compress bool, serviceName string) *zap.Logger

Types

type LoggerBase

type LoggerBase struct {
	Logger      *zap.Logger
	WriteToAll  bool
	ServiceName string
}

func (LoggerBase) Debug

func (log LoggerBase) Debug(msg string, fields ...zapcore.Field)

func (LoggerBase) Error

func (log LoggerBase) Error(msg string, fields ...zapcore.Field)

func (LoggerBase) Fatal

func (log LoggerBase) Fatal(msg string, fields ...zapcore.Field)

func (LoggerBase) Info

func (log LoggerBase) Info(msg string, fields ...zapcore.Field)

func (LoggerBase) Warn

func (log LoggerBase) Warn(msg string, fields ...zapcore.Field)

Jump to

Keyboard shortcuts

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