Skip to content

nkien0204/rolling-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rolling-logger

A helpful tool for separating log file by time!

How to use

package main

import (
	"github.com/nkien0204/rolling-logger/rolling"
)

func main() {
	logger := rolling.New()
	defer logger.Sync()

	logger.Info("hello logger")
	logger.Error("got error")
	logger.Debug("this is debug")
}

Some basic configurations are on the config.yaml file. So make sure that it available to load this configuration.

Let's take a look at config.yaml:

  • log_rotation_time: (day|hour|min) for "daily", "hourly" or "every minute" log file separation (default is hour).
  • log_info_dir/log_info_name: location of log files which have the level greater or equal to INFO.
  • log_debug_dir/log_debug_name: location of log files which have the level less than INFO.

Log level order: DEBUG < INFO < WARN < ERROR < PANIC < FATAL

Tracking the latest log: logger.log and logger-debug.log (in case using DEBUG log level)

Dependencies

About

Time rotation logger integrate with uber-go/zap

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages