logger

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 9 Imported by: 28

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

CurrentFileName 当前日志文件名

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

LogLinkFileFPath returns the path of the log file that is linked to the current log writer.

func NewLogHelper

func NewLogHelper(settings *Settings) *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 SetLoggerSettings added in v0.0.11

func SetLoggerSettings(inSettings ...*Settings)

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

type Settings added in v0.0.11

type Settings struct {
	OnlyMsg      bool          // 是否只输出消息内容
	Level        logrus.Level  // 日志级别
	LogRootFPath string        // 日志根目录
	LogNameBase  string        // 日志名称
	RotationTime time.Duration // 日志轮转时间
	MaxAge       time.Duration // 日志最大保存时间
}

func NewSettings added in v0.0.11

func NewSettings() *Settings

NewSettings 创建一个新的日志设置

Jump to

Keyboard shortcuts

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