logger

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 9 Imported by: 21

README

logger

How to use

The duration for recording a single log file is 24 hours. After the duration exceeds 24 hours, a log file is automatically divided. All logs can be stored for a maximum of 7 x 24 hours.

Def use

Logs are stored in the Log folder under the current program. The default log level is Info.

logger.SetLoggerName("AppName")
logger.Info("haha")
// will save like AppName.log
Change log level
logger.SetLoggerName("AppName")
logger.Info("haha")
// [INFO]: 2022-02-11 08:51:16 - haha
logger.SetLoggerLevel(logrus.InfoLevel)
logger.Debug("haha")
// [DEBUG]: 2022-02-11 08:51:16 - haha
Set log file save path

By default, will save at ./Logs/

logger.SetLoggerRootDir("/config/xxx")
// will save at /config/xxx/Logs
Set logger name

By default, will save log files like: logger.log

logger.SetLoggerName("AppName")
// will save like AppName.log

Base on

Documentation

Index

Constants

View Source
const (
	NameDef = "logger"
)

Variables

This section is empty.

Functions

func CurrentFileName added in v0.0.6

func CurrentFileName() string

func Debug

func Debug(args ...interface{})

func Debugf

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

func Debugln

func Debugln(args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func Fatalln

func Fatalln(args ...interface{})

func GetLogger added in v0.0.2

func GetLogger() *logrus.Logger

func Info

func Info(args ...interface{})

func Infof

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

func Infoln

func Infoln(args ...interface{})

func LogLinkFileFPath added in v0.0.6

func LogLinkFileFPath() string

func NewLogHelper

func NewLogHelper(logRootDirFPath, appName string, level logrus.Level, maxAge time.Duration, rotationTime time.Duration) *logrus.Logger

func NewLogger added in v0.0.4

func NewLogger(logRootDirFPath, logFileName string) *logrus.Logger

func Panic

func Panic(args ...interface{})

func Panicf

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

func Panicln

func Panicln(args ...interface{})

func Print

func Print(args ...interface{})

func Printf

func Printf(format string, args ...interface{})

func Println

func Println(args ...interface{})

func SetLoggerLevel

func SetLoggerLevel(level logrus.Level)

func SetLoggerName

func SetLoggerName(logName string)

func SetLoggerRootDir

func SetLoggerRootDir(loggerRootDir string)

func Warn

func Warn(args ...interface{})

func Warnf

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

func Warning

func Warning(args ...interface{})

func Warningf

func Warningf(format string, args ...interface{})

func Warningln

func Warningln(args ...interface{})

func Warnln

func Warnln(args ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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