Categorygithub.com/restoflife/log
modulepackage
1.0.2
Repository: https://github.com/restoflife/log.git
Documentation: pkg.go.dev

# README

log_test

    package app

    import "github.com/restoflife/log"

    func Init()  {
		log.New(&log.Config{
			Level:    "error",
			Filename: "error.log",
		})
		defer log.Sync()
		log.Info("info","info")
    }


func (b *Base) InitLogger() {
	run := &log.Config{
		Level:      conf.LogConfig.Run.Level,
		Filename:   conf.LogConfig.Run.Filename,
		MaxSize:    conf.LogConfig.Run.MaxSize,
		MaxBackups: conf.LogConfig.Run.MaxBackups,
		MaxAge:     conf.LogConfig.Run.MaxAge,
	}
	log.New(run)
	defer run.Sync()
	ginLog := &log.Config{
		Level:      conf.LogConfig.Gin.Level,
		Filename:   conf.LogConfig.Gin.Filename,
		MaxSize:    conf.LogConfig.Gin.MaxSize,
		MaxBackups: conf.LogConfig.Gin.MaxBackups,
		MaxAge:     conf.LogConfig.Gin.MaxAge,
	}
	b.Log, _ = ginLog.NewLogger()
	defer ginLog.Sync()

}
func d()  {
	sqlLog := &log.Config{
		// Set the log level
		Level: conf.LogConfig.Sql.Level,
		// Set the log filename
		Filename: conf.LogConfig.Sql.Filename,
		// Set the maximum file size
		MaxSize: conf.LogConfig.Sql.MaxSize,
		// Set the maximum number of backups
		MaxBackups: conf.LogConfig.Sql.MaxBackups,
		// Set the maximum age of log files
		MaxAge: conf.LogConfig.Sql.MaxAge,
	}
	sqlLogs, err := sqlLog.NewLogger()
	if err != nil {
		return err
	}
	db.SetLogger(log.NewXormLogger(sqlLogs))
}

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GinLogger instances a Logger middleware that will write the logs to gin.DefaultWriter.
No description provided by the author
Logger This function returns a pointer to the logger.
New Create a new logger using the configuration.
NewElasticLogger Create a new ElasticsearchLog struct with the given zapLogger, requestBody and responseBody.
NewGormLogger creates a new GormLogger instance.
NewXormLogger Create a new XormLogger with the given zapLogger.
No description provided by the author
Recovery This function is used to recover from panic and log the error.
WithConfig instance a Logger middleware with config.
WithWriter instance a Logger middleware with the specified writer buffer.

# Constants

GORM defines the prefix of the log entry from GORM.
SQL defines the prefix of the log entry from SQL.
XORM defines the prefix of the log entry from XORM.

# Structs

No description provided by the author
ConfigGin defines the config for Logger middleware.
No description provided by the author
FormatterParams is the structure any formatter will be handed when time to log comes.
No description provided by the author
No description provided by the author