zlogwriter

package
v0.0.0-...-5f8f03c Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWriter

type FileWriter struct {
	sync.RWMutex // write log order by order and atomic incr maxLinesCurLines and maxSizeCurSize
	// The opened file
	Filename string `json:"filename"`

	// Rotate at line
	MaxLines int `json:"maxlines"`

	// Rotate at size
	MaxSize int `json:"maxsize"`

	// Rotate daily
	Daily   bool  `json:"daily"`
	MaxDays int64 `json:"maxdays"`

	Rotate bool `json:"rotate"`

	Perm string `json:"perm"`

	RotatePerm string `json:"rotateperm"`
	// contains filtered or unexported fields
}

FileWriter implements io.Writer interface It writes messages by lines limit, file size limit, or time frequency.

func NewFileWriter

func NewFileWriter() *FileWriter

NewFileWriter create a FileWriter

func (*FileWriter) Destroy

func (w *FileWriter) Destroy()

Destroy close the file description, close file writer.

func (*FileWriter) Flush

func (w *FileWriter) Flush()

Flush flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.

func (*FileWriter) Init

func (w *FileWriter) Init(jsonConfig string) error

Init file logger with json config. jsonConfig like:

	{
	"filename":"logs/beego.log",
	"maxLines":10000,
	"maxsize":1024,
	"daily":true,
	"maxDays":15,
	"rotate":true,
 	"perm":"0600"
	}

func (*FileWriter) Write

func (w *FileWriter) Write(p []byte) (n int, err error)

Write write logger message into file.

Jump to

Keyboard shortcuts

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