Documentation ¶
Index ¶
- Constants
- func AddDyeingUser(key string) error
- func Colored()
- func FlushLogger()
- func GetAllDyeingUser() []string
- func GetDyeingLogQueue() *chan *dyeingLogValue
- 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 SetLevel(level LogLevel)
- type ConsoleWriter
- type DateType
- type DateWriter
- type HourWriter
- 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) SetWriter(w LogWriter)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- 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 ¶
AddDyeingUser add dyeing key to dyeingUserMap. key is separated by ','
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 HandleDyeingAdmin ¶
HandleDyeingAdmin handle the dyeing key operation from admin. For example add a dyeing key. Send "dyeUserManage help" from admin, will see help.
func IsDyeingUser ¶
IsDyeingUser return whether dyeingKey exist in dyeingUserMap
func RemoveDyeingUser ¶
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 SetDyeingUser ¶
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 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 wirter.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug logs interface in debug loglevel.
func (*Logger) DyeingDebug ¶
func (*Logger) DyeingDebugf ¶
func (*Logger) DyeingError ¶
func (*Logger) DyeingErrorf ¶
func (*Logger) DyeingInfo ¶
func (*Logger) DyeingInfof ¶
func (*Logger) DyeingWarn ¶
func (*Logger) DyeingWarnf ¶
func (*Logger) DyeingWritef ¶
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) Warn ¶
func (l *Logger) Warn(v ...interface{})
Warn logs interface in warning loglevel
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.