rogger

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Admin = "dyeUserManage"
)

Variables

This section is empty.

Functions

func AddDyeingUser

func AddDyeingUser(key string) error

AddDyeingUser add dyeing key to dyeingUserMap. key is separated by ','

func Colored

func Colored()

Colored enable colored level string when use console writer

func FlushLogger

func FlushLogger()

FlushLogger flushs all log to disk.

func GetAllDyeingUser

func GetAllDyeingUser() []string

GetAllDyeingUser get all dyeing key from dyeingUserMap. key is separated by ','

func GetDyeingLogQueue

func GetDyeingLogQueue() *chan *dyeingLogValue

GetDyeingLogQue get dyeingLogQueue, which will contain dyeing log if dyeing switch is on(by call DyeingSwitch). If dyeing switch is on, user must guarantee the dyeingLogQueue can be continuous consumed in case of goroutine blocked.

func GetLevel

func GetLevel() string

GetLevel get global log level and return string

func HandleDyeingAdmin

func HandleDyeingAdmin(command string) (string, error)

HandleDyeingAdmin handle the dyeing key operation from admin. For example add a dyeing key. Send "dyeUserManage help" from admin, will see help.

func IsDyeingUser

func IsDyeingUser(key string) bool

IsDyeingUser return whether dyeingKey exist in dyeingUserMap

func RemoveDyeingUser

func RemoveDyeingUser(key string) error

RemoveDyeingUser remove dyeing key from dyeingUserMap. key is separated by ','

func SetCallerFlag

func SetCallerFlag(flag bool)

SetCallerFlag enable/disable caller string when write log

func SetCallerSkip

func SetCallerSkip(skip int)

SetCallerSkip sets the caller skip

func SetDyeingUser

func SetDyeingUser(v []string)

SetDyeingUser set dyeing key to dyeingUserMap(overwrite)

func SetLevel

func SetLevel(level LogLevel)

SetLevel sets the log level

Types

type ConsoleWriter

type ConsoleWriter struct {
}

ConsoleWriter writes the logs to the console.

func (*ConsoleWriter) NeedPrefix

func (w *ConsoleWriter) NeedPrefix() bool

NeedPrefix shows whether needs the prefix for the console writer.

func (*ConsoleWriter) Write

func (w *ConsoleWriter) Write(v []byte)

type DateType

type DateType uint8

DateType is uint8

const (
	DAY DateType = iota
	HOUR
)

DAY for rotate log by day

type DateWriter

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

DateWriter rotate logs by date.

func NewDateWriter

func NewDateWriter(logpath, name string, dateType DateType, num int) *DateWriter

NewDateWriter returns a writer which keeps logs in hours or day format.

func (*DateWriter) NeedPrefix

func (w *DateWriter) NeedPrefix() bool

NeedPrefix shows whether needs prefix info for DateWriter or not.

func (*DateWriter) SetPrefix

func (w *DateWriter) SetPrefix(enable bool)

func (*DateWriter) Write

func (w *DateWriter) Write(v []byte)

Write method implement for the DateWriter

type HourWriter

type HourWriter struct {
}

HourWriter for rotate logs by hour

type LogLevel

type LogLevel uint8

LogLevel is uint8 type

const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
	OFF
)

DEBUG loglevel

func GetLogLevel

func GetLogLevel() LogLevel

GetLogLevel get global log level

func StringToLevel

func StringToLevel(level string) LogLevel

StringToLevel turns string to LogLevel

func (*LogLevel) String

func (lv *LogLevel) String() string

String turns the LogLevel to string.

type LogWriter

type LogWriter interface {
	Write(v []byte)
	NeedPrefix() bool
}

LogWriter is interface for different writer.

type Logger

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

Logger is the struct with name and wirter.

func GetLogger

func GetLogger(name string) *Logger

GetLogger return an logger instance

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

Debug logs interface in debug loglevel.

func (*Logger) Debugf

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

Debugf logs interface in debug loglevel with formating string

func (*Logger) DyeingDebug

func (l *Logger) DyeingDebug(ctx context.Context, ext interface{}, v ...interface{})

func (*Logger) DyeingDebugf

func (l *Logger) DyeingDebugf(ctx context.Context, ext interface{}, format string, v ...interface{})

func (*Logger) DyeingError

func (l *Logger) DyeingError(ctx context.Context, ext interface{}, v ...interface{})

func (*Logger) DyeingErrorf

func (l *Logger) DyeingErrorf(ctx context.Context, ext interface{}, format string, v ...interface{})

func (*Logger) DyeingInfo

func (l *Logger) DyeingInfo(ctx context.Context, ext interface{}, v ...interface{})

func (*Logger) DyeingInfof

func (l *Logger) DyeingInfof(ctx context.Context, ext interface{}, format string, v ...interface{})

func (*Logger) DyeingWarn

func (l *Logger) DyeingWarn(ctx context.Context, ext interface{}, v ...interface{})

func (*Logger) DyeingWarnf

func (l *Logger) DyeingWarnf(ctx context.Context, ext interface{}, format string, v ...interface{})

func (*Logger) DyeingWritef

func (l *Logger) DyeingWritef(ctx context.Context, depth int, level LogLevel, ext interface{}, format string, v []interface{})

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

Error logs interface in Error loglevel

func (*Logger) Errorf

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

Errorf logs interface in Error loglevel with formating string

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

Info logs interface in Info loglevel.

func (*Logger) Infof

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

Infof logs interface in Infof loglevel with formating string

func (*Logger) IsConsoleWriter

func (l *Logger) IsConsoleWriter() bool

IsConsoleWriter returns whether is consoleWriter or not.

func (*Logger) SetConsole

func (l *Logger) SetConsole()

SetConsole sets the logger with console writer.

func (*Logger) SetDayRoller

func (l *Logger) SetDayRoller(logpath string, num int) error

SetDayRoller sets the logger to rotate by day, with max num files.

func (*Logger) SetFileRoller

func (l *Logger) SetFileRoller(logpath string, num int, sizeMB int) error

SetFileRoller sets the file rolled by size in MB, with max num of files.

func (*Logger) SetHourRoller

func (l *Logger) SetHourRoller(logpath string, num int) error

SetHourRoller sets the logger to rotate by hour, with max num files.

func (*Logger) SetLogName

func (l *Logger) SetLogName(name string)

SetLogName sets the log name

func (*Logger) SetWriter

func (l *Logger) SetWriter(w LogWriter)

SetWriter sets the writer to the logger.

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

Warn logs interface in warning loglevel

func (*Logger) Warnf

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

Warnf logs interface in warning loglevel with formating string

func (*Logger) WriteLog

func (l *Logger) WriteLog(msg []byte)

WriteLog write log into log files ignore the log level and log prefix

func (*Logger) Writef

func (l *Logger) Writef(depth int, level LogLevel, format string, v []interface{})

type RollFileWriter

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

RollFileWriter struct for rotate logs by file size.

func NewRollFileWriter

func NewRollFileWriter(logpath, name string, num, sizeMB int) *RollFileWriter

NewRollFileWriter returns a RollFileWriter, rotate logs in sizeMB , and num files are keeped.

func (*RollFileWriter) NeedPrefix

func (w *RollFileWriter) NeedPrefix() bool

NeedPrefix shows need prefix or not.

func (*RollFileWriter) Write

func (w *RollFileWriter) Write(v []byte)

Write for writing []byte to the writter.

Jump to

Keyboard shortcuts

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