Skip to content

TimeWriter implements io.Writer to roll daily and comporess log file time

Notifications You must be signed in to change notification settings

longbozhan/timewriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimeWriter

TimeWriter implements io.Writer to roll daily and comporess log file time

Overview

  • implements io.Writer. You can easily use in golang log, GORM, grpclog etc.
  • daily roll log, you can specific the log file name's prefix, default is process name
  • compress to gz for old file

Getting Started

Example

To use TimeWriter, you can git clone https://github.com/longbozhan/timewriter, and import like this:

package main

import (
	"log"
)

func main() {
	timeWriter := &TimeWriter{
		Dir:        "./log",
		Compress:   true,
		ReserveDay: 30,
	}
	logDebug := log.New(timeWriter, " [Debug] ", log.LstdFlags)
	logDebug.Println("this is debug")
}

Reference

About

TimeWriter implements io.Writer to roll daily and comporess log file time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages