loghub

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG = iota
	INFO
	WARN
	ERROR
	FATAL
)

Variables

View Source
var (
	AccessLogFormat = "%s"
	AccessLogFlag   = (log.Ldate | log.Ltime | log.Lmicroseconds)
	AccessLogger    *Logger
)
View Source
var (
	AnalysisLogFormat = "%s"
	AnalysisLogFlag   = log.LstdFlags | log.Lmicroseconds
	AnalysisLogger    *Logger
)
View Source
var (
	ErrorLogFormat = "%s %15s:%4d - %s"
	ErrorLogFlag   = (log.LstdFlags | log.Lmicroseconds)
	ErrorLogger    *Logger
)

Functions

func GetStack

func GetStack(size int) string

func InitAccessLog

func InitAccessLog(path string, level int) (err error)

func InitAnalysisLog

func InitAnalysisLog(path string, level int, bufferSize int) (err error)

func InitErrorLog

func InitErrorLog(path string, level int, bufferSize int) (err error)

func InitLogger

func InitLogger(errorlog, accesslog, analysislog string)

Types

type AccessLogHub

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

func (*AccessLogHub) DumpBuffer

func (hub *AccessLogHub) DumpBuffer(all bool, out io.Writer)

func (*AccessLogHub) GetLastLog

func (hub *AccessLogHub) GetLastLog() []byte

func (*AccessLogHub) Log

func (hub *AccessLogHub) Log(name string, level int, file string, line int, msg string)

func (*AccessLogHub) Reopen

func (hub *AccessLogHub) Reopen(path string) (err error)

type AnalysisLogHub

type AnalysisLogHub struct {
	BufferLog
	// contains filtered or unexported fields
}

func (*AnalysisLogHub) Log

func (hub *AnalysisLogHub) Log(name string, level int, file string, line int, msg string)

func (*AnalysisLogHub) Reopen

func (hub *AnalysisLogHub) Reopen(path string) (err error)

type BufferLine

type BufferLine struct {
	TS    time.Time
	Level int
	File  string
	Line  int
	Msg   string
}

type BufferLog

type BufferLog struct {
	sync.Mutex

	Buffer []*BufferLine

	Last [FATAL + 1]*BufferLine
	// contains filtered or unexported fields
}

func (*BufferLog) Add

func (l *BufferLog) Add(line *BufferLine)

func (*BufferLog) DumpBuffer

func (l *BufferLog) DumpBuffer(all bool, out io.Writer)

func (*BufferLog) GetLastLog

func (l *BufferLog) GetLastLog() []byte

func (*BufferLog) InitBuffer

func (l *BufferLog) InitBuffer(size int)

type DemoHub

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

func NewDemoHub

func NewDemoHub() *DemoHub

func (*DemoHub) Bind

func (l *DemoHub) Bind(name string, config *DemoHubConfig)

func (*DemoHub) DumpBuffer

func (l *DemoHub) DumpBuffer(all bool, out io.Writer)

func (*DemoHub) GetLastLog

func (l *DemoHub) GetLastLog() []byte

func (*DemoHub) Log

func (l *DemoHub) Log(name string, level int, file string, line int, msg string)

func (*DemoHub) Reopen

func (l *DemoHub) Reopen(path string) error

type DemoHubConfig

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

type ErrorLogHub

type ErrorLogHub struct {
	BufferLog
	// contains filtered or unexported fields
}

func (*ErrorLogHub) Log

func (hub *ErrorLogHub) Log(name string, level int, file string, line int, msg string)

func (*ErrorLogHub) Reopen

func (hub *ErrorLogHub) Reopen(path string) (err error)

type LogHub

type LogHub interface {
	Log(name string, level int, file string, line int, msg string)
	Reopen(path string) error
	GetLastLog() []byte
	DumpBuffer(all bool, out io.Writer)
}

type Logger

type Logger struct {
	Hub LogHub
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(name string, hub LogHub, minLevel int) *Logger

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

func (*Logger) Logf

func (l *Logger) Logf(level int, format string, v ...interface{})

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...interface{})

Jump to

Keyboard shortcuts

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