log

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package log is used to collect information of running application and then transport them to destination.

Package log plan to provide a log collect component that can output application log to console and file meanwhile. In addition, log that is exported to file can be rotated automatically by Mode and file size.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustNewLogger

func MustNewLogger(logConfig *config.Log) (logger *logging.Logger)

MustNewLogger just call NewLogger, but if there are errors, process will

func NewLogger

func NewLogger(logConfig *config.Log) (logger *logging.Logger, err error)

NewLogger is used to get a log collector, there is only a single instance globally

Types

type AutoRotateWriter

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

AutoRotateWriter implement io.Writer interface, this writer will write content to different file by configuration.

func NewAutoRotateWriter

func NewAutoRotateWriter(file string, maxBytes uint64) (*AutoRotateWriter, error)

NewAutoRotateWriter is used return a writer, that will change to another writer when the size of current file will be up to maxBytes.

func (*AutoRotateWriter) Close

func (a *AutoRotateWriter) Close() error

Close is used to implement io.Close

func (*AutoRotateWriter) Write

func (a *AutoRotateWriter) Write(p []byte) (n int, err error)

Write is used to implement io.Writer, because of mutex before write, this will lead to a bad performance. I will optimize this in the future. TODO: optimize performance

Jump to

Keyboard shortcuts

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