xlog4go

package module
v0.0.0-...-896a7cd Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: GPL-2.0 Imports: 13 Imported by: 1

README

xlog4go

another log4go

Features

  • json conf file
  • support rotate by year/month/day/hour
  • detached file for warning/fatal level
  • record file name and line number

Install

$ go get github.com/shengkehua/xlog4go

Conf

see log.json

Use

see main.go

Documentation

Index

Constants

View Source
const (
	TRACE = iota
	DEBUG
	INFO
	WARNING
	ERROR
	FATAL
)

Variables

View Source
var (
	LEVEL_FLAGS = [...]string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"}
)

Functions

func Close

func Close()

func Debug

func Debug(fmt string, args ...interface{})

func Error

func Error(fmt string, args ...interface{})

func Fatal

func Fatal(fmt string, args ...interface{})

func Info

func Info(fmt string, args ...interface{})

func Register

func Register(w Writer)

func SetLayout

func SetLayout(layout string)

func SetLevel

func SetLevel(lvl int)

func SetupLogWithFile

func SetupLogWithFile(file string) (err error)

func SetupLogWithJson

func SetupLogWithJson(cnt []byte) (err error)

func SetupLogWithPtr

func SetupLogWithPtr(lc *LogConfig) (err error)

func Trace

func Trace(fmt string, args ...interface{})

func Warn

func Warn(fmt string, args ...interface{})

Types

type ConfConsoleWriter

type ConfConsoleWriter struct {
	On    bool `json:"On"`
	Color bool `json:"Color"`
}

type ConfFileWriter

type ConfFileWriter struct {
	On              bool   `json:"On"`
	LogPath         string `json:"LogPath"`
	RotateLogPath   string `json:"RotateLogPath"`
	WfLogPath       string `json:"WfLogPath"`
	RotateWfLogPath string `json:"RotateWfLogPath"`
}

type ConsoleWriter

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

func NewConsoleWriter

func NewConsoleWriter() *ConsoleWriter

func (*ConsoleWriter) Init

func (w *ConsoleWriter) Init() error

func (*ConsoleWriter) SetColor

func (w *ConsoleWriter) SetColor(c bool)

func (*ConsoleWriter) Write

func (w *ConsoleWriter) Write(r *Record) error

type FileWriter

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

func NewFileWriter

func NewFileWriter() *FileWriter

func (*FileWriter) CreateLogFile

func (w *FileWriter) CreateLogFile() error

func (*FileWriter) Flush

func (w *FileWriter) Flush() error

func (*FileWriter) Init

func (w *FileWriter) Init() error

func (*FileWriter) Rotate

func (w *FileWriter) Rotate() error

func (*FileWriter) SetFileName

func (w *FileWriter) SetFileName(filename string)

func (*FileWriter) SetLogLevelCeil

func (w *FileWriter) SetLogLevelCeil(ceil int)

func (*FileWriter) SetLogLevelFloor

func (w *FileWriter) SetLogLevelFloor(floor int)

func (*FileWriter) SetPathPattern

func (w *FileWriter) SetPathPattern(pattern string) error

func (*FileWriter) Write

func (w *FileWriter) Write(r *Record) error

type Flusher

type Flusher interface {
	Flush() error
}

type LogConfig

type LogConfig struct {
	Level string            `json:"LogLevel"`
	FW    ConfFileWriter    `json:"FileWriter"`
	CW    ConfConsoleWriter `json:"ConsoleWriter"`
}

type Logger

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

func NewLogger

func NewLogger() *Logger

func (*Logger) Close

func (l *Logger) Close()

func (*Logger) Debug

func (l *Logger) Debug(fmt string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(fmt string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(fmt string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(fmt string, args ...interface{})

func (*Logger) Register

func (l *Logger) Register(w Writer)

func (*Logger) SetLayout

func (l *Logger) SetLayout(layout string)

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl int)

func (*Logger) Trace

func (l *Logger) Trace(fmt string, args ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(fmt string, args ...interface{})

type Record

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

func (*Record) String

func (r *Record) String() string

type Rotater

type Rotater interface {
	Rotate() error
	SetPathPattern(string) error
}

type Writer

type Writer interface {
	Init() error
	Write(*Record) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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