logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 5 Imported by: 0

README

logger

package main

import (
	"github.com/PengShaw/go-common/logger"
)

func main(){
	logger.InitLogger()
	//logger.InitLoggerByOptions(&logger.Options{Filename: "./test.log"})
	//log :=  logger.GetLogger()
	//log :=  logger.GetLoggerByOptions(&logger.Options{Filename: "./test.log"})

	logger.Info("info ok")
	logger.Infof("info $s","ok")
	//log.Info("info ok")
	//log.Infof("info $s","ok")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func InitLogger

func InitLogger()

func InitLoggerByOptions

func InitLoggerByOptions(options *Options)

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(template string, args ...interface{})

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

Types

type Logger

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

func GetLogger

func GetLogger() *Logger

func GetLoggerByOptions

func GetLoggerByOptions(options *Options) *Logger

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(template string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(template string, args ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(template string, args ...interface{})

type Options

type Options struct {
	Level      string
	Json       bool   // 是否 json 格式
	Filename   string //日志文件位置
	MaxSize    int    // 单文件最大容量,单位是MB
	MaxBackups int    // 最大保留过期文件个数
	MaxAge     int    // 保留过期文件的最大时间间隔,单位是天
	Compress   bool   // 是否需要压缩滚动日志, 使用的 gzip 压缩
}

Jump to

Keyboard shortcuts

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