rotator

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: MIT Imports: 9 Imported by: 0

README

Echo logger with rotator

Usage

package main

import ()
	"github.com/labstack/echo"
	"github.com/silentred/rotator"
)

// Echo is the web engine
var Echo *echo.Echo

func init() {
	Echo = echo.New()
}

func main() {
	initLogger()
    Echo.Logger.Info("test")
	Echo.Start(":8090")
}

func initLogger() {
	path := "storage/log"
	appName := "app"
	limitSize := 100 << 20 // 100MB

	r := rotator.NewFileSizeRotator(path, appName, "log", limitSize)
	Echo.Logger.SetOutput(r) 
	Echo.Logger.SetLevel(elog.WARN)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaySpliter

type DaySpliter struct {
	// contains filtered or unexported fields
}

DaySpliter rotates log file by day

func NewDaySpliter

func NewDaySpliter() *DaySpliter

NewDaySpliter gets a new DaySpliter

type FileRotator

type FileRotator struct {

	// clean older log file
	Clean bool
	// contains filtered or unexported fields
}

func NewFileRotator

func NewFileRotator(path, prefix, ext string, splt Spliter) *FileRotator

func (*FileRotator) Write

func (r *FileRotator) Write(p []byte) (n int, err error)

type RotatorWriter

type RotatorWriter interface {
	io.Writer
}

type SizeSpliter

type SizeSpliter struct {
	// contains filtered or unexported fields
}

SizeSpliter rotates log file by size

func NewSizeSpliter

func NewSizeSpliter(limit uint64) *SizeSpliter

NewSizeSpliter return a new SizeSpliter

type Spliter

type Spliter interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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