easylog

package module
v1.0.2 Latest Latest
Warning

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

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

README

easylog

golang logger

golang logger library. features:

  1. set max file count automatically delete old files on disk
  2. set max file size when on log file size exceed some threshold, then switch to another log file
  3. support log levels

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EasyLog

type EasyLog struct {
	SaveDir      string
	FileName     string
	MaxFileSize  int64
	MaxFileCount int64
	FlushFreq    time.Duration

	Pipe chan *bytes.Buffer
	// contains filtered or unexported fields
}

func NewLog

func NewLog(buflen int, FlushFreq time.Duration) *EasyLog

func (*EasyLog) SetDir

func (t *EasyLog) SetDir(szDir string, FileName string) error

set where to store logs, and the log file's name

func (*EasyLog) SetMaxFileCount

func (t *EasyLog) SetMaxFileCount(MaxFileCount int64) error

set max log file count if MaxFileCount == 0, no file count limited. if MaxFileCount > 0 and actual file count > MaxFileCount, then the earliest log file will be deleted.

func (*EasyLog) SetMaxFileSize

func (t *EasyLog) SetMaxFileSize(MaxFileSize int64) error

set single file max size. if the file size exceeds MaxFileSize, then a new file will be created to store log info

func (*EasyLog) Write

func (t *EasyLog) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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