Documentation ¶
Index ¶
- Constants
- func AddDyeingUser(key string) error
- func Colored()
- func FlushLogger()
- func GetAllDyeingUser() []string
- func GetDyeingLogQueue() *chan *dyeingLogValue
- func GetFormat() string
- func GetLevel() string
- func HandleDyeingAdmin(command string) (string, error)
- func IsDyeingUser(key string) bool
- func RemoveDyeingUser(key string) error
- func SetCallerFlag(flag bool)
- func SetCallerSkip(skip int)
- func SetDyeingUser(v []string)
- func SetFormat(format LogFormat)
- func SetLevel(level LogLevel)
- type ConsoleWriter
- type DateType
- type DateWriter
- type HourWriter
- type JsonLog
- type LogFormat
- type LogLevel
- type LogWriter
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) DyeingDebug(ctx context.Context, ext interface{}, v ...interface{})
- func (l *Logger) DyeingDebugf(ctx context.Context, ext interface{}, format string, v ...interface{})
- func (l *Logger) DyeingError(ctx context.Context, ext interface{}, v ...interface{})
- func (l *Logger) DyeingErrorf(ctx context.Context, ext interface{}, format string, v ...interface{})
- func (l *Logger) DyeingInfo(ctx context.Context, ext interface{}, v ...interface{})
- func (l *Logger) DyeingInfof(ctx context.Context, ext interface{}, format string, v ...interface{})
- func (l *Logger) DyeingWarn(ctx context.Context, ext interface{}, v ...interface{})
- func (l *Logger) DyeingWarnf(ctx context.Context, ext interface{}, format string, v ...interface{})
- func (l *Logger) DyeingWritef(ctx context.Context, depth int, level LogLevel, ext interface{}, format string, ...)
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) IsConsoleWriter() bool
- func (l *Logger) SetConsole()
- func (l *Logger) SetDayRoller(logpath string, num int) error
- func (l *Logger) SetFileRoller(logpath string, num int, sizeMB int) error
- func (l *Logger) SetHourRoller(logpath string, num int) error
- func (l *Logger) SetLogName(name string)
- func (l *Logger) SetLogPrefix(pre string)
- func (l *Logger) SetWriter(w LogWriter)
- func (l *Logger) Trace(msg string)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- func (l *Logger) WriteJsonF(depth int, level LogLevel, format string, v []interface{}) *logValue
- func (l *Logger) WriteLineF(depth int, level LogLevel, format string, v []interface{}) *logValue
- func (l *Logger) WriteLog(msg []byte)
- func (l *Logger) Writef(depth int, level LogLevel, format string, v []interface{})
- type RollFileWriter
Constants ¶
const (
Admin = "dyeUserManage"
)
Variables ¶
This section is empty.
Functions ¶
func AddDyeingUser ¶ added in v1.1.2
AddDyeingUser add dyeing key to dyeingUserMap. key is separated by ','
func GetAllDyeingUser ¶ added in v1.1.2
func GetAllDyeingUser() []string
GetAllDyeingUser get all dyeing key from dyeingUserMap. key is separated by ','
func GetDyeingLogQueue ¶ added in v1.1.2
func GetDyeingLogQueue() *chan *dyeingLogValue
GetDyeingLogQueue 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 GetFormat ¶ added in v1.3.3
func GetFormat() string
GetFormat get global log format and return string
func GetLevel ¶ added in v1.1.2
func GetLevel() string
GetLevel get global log level and return string
func HandleDyeingAdmin ¶ added in v1.1.2
HandleDyeingAdmin handle the dyeing key operation from admin. For example add a dyeing key. Send "dyeUserManage help" from admin, will see help.
func IsDyeingUser ¶ added in v1.1.2
IsDyeingUser return whether dyeingKey exist in dyeingUserMap
func RemoveDyeingUser ¶ added in v1.1.2
RemoveDyeingUser remove dyeing key from dyeingUserMap. key is separated by ','
func SetCallerFlag ¶ added in v1.1.2
func SetCallerFlag(flag bool)
SetCallerFlag enable/disable caller string when write log
func SetCallerSkip ¶ added in v1.1.2
func SetCallerSkip(skip int)
SetCallerSkip sets the caller skip
func SetDyeingUser ¶ added in v1.1.2
func SetDyeingUser(v []string)
SetDyeingUser set dyeing key to dyeingUserMap(overwrite)
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 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 LogFormat ¶ added in v1.3.3
type LogFormat uint8
LogFormat is uint8 format
func GetLogFormat ¶ added in v1.3.3
func GetLogFormat() LogFormat
GetLogFormat get global log format
type LogLevel ¶
type LogLevel uint8
LogLevel is uint8 type
func StringToLevel ¶
StringToLevel turns string to LogLevel
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the struct with name and writer.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug logs interface in debug loglevel.
func (*Logger) DyeingDebug ¶ added in v1.1.2
func (*Logger) DyeingDebugf ¶ added in v1.1.2
func (*Logger) DyeingError ¶ added in v1.1.2
func (*Logger) DyeingErrorf ¶ added in v1.1.2
func (*Logger) DyeingInfo ¶ added in v1.1.2
func (*Logger) DyeingInfof ¶ added in v1.1.2
func (*Logger) DyeingWarn ¶ added in v1.1.2
func (*Logger) DyeingWarnf ¶ added in v1.1.2
func (*Logger) DyeingWritef ¶ added in v1.1.2
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error logs interface in Error loglevel
func (*Logger) IsConsoleWriter ¶
IsConsoleWriter returns whether is consoleWriter or not.
func (*Logger) SetConsole ¶
func (l *Logger) SetConsole()
SetConsole sets the logger with console writer.
func (*Logger) SetDayRoller ¶
SetDayRoller sets the logger to rotate by day, with max num files.
func (*Logger) SetFileRoller ¶
SetFileRoller sets the file rolled by size in MB, with max num of files.
func (*Logger) SetHourRoller ¶
SetHourRoller sets the logger to rotate by hour, with max num files.
func (*Logger) SetLogPrefix ¶ added in v1.3.7
SetLogPrefix sets the log line prefix
func (*Logger) Warn ¶
func (l *Logger) Warn(v ...interface{})
Warn logs interface in warning loglevel
func (*Logger) WriteJsonF ¶ added in v1.3.3
func (*Logger) WriteLineF ¶ added in v1.3.3
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 writer.