Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteFileFilter(info os.FileInfo, diskSpaceLeft int64) bool
- func GetLog(w http.ResponseWriter, r *http.Request)
- func LogCritical(v ...interface{})
- func LogCriticalf(format string, v ...interface{})
- func LogDebug(v ...interface{})
- func LogDebugf(format string, v ...interface{})
- func LogError(v ...interface{})
- func LogErrorf(format string, v ...interface{})
- func LogFatal(v ...interface{})
- func LogFatalf(format string, v ...interface{})
- func LogFlush()
- func LogInfo(v ...interface{})
- func LogInfof(format string, v ...interface{})
- func LogRead(v ...interface{})
- func LogReadf(format string, v ...interface{})
- func LogWarn(v ...interface{})
- func LogWarnf(format string, v ...interface{})
- func LogWrite(v ...interface{})
- func LogWritef(format string, v ...interface{})
- func OutputPid(logDir, role string) error
- func SetLogLevel(w http.ResponseWriter, r *http.Request)
- type HTTPReply
- type Level
- type Log
- type LogObject
- type LogRotate
- type RolledFile
Constants ¶
View Source
const ( DebugLevel Level = 1 InfoLevel = DebugLevel<<1 + 1 WarnLevel = InfoLevel<<1 + 1 ErrorLevel = WarnLevel<<1 + 1 FatalLevel = ErrorLevel<<1 + 1 CriticalLevel = FatalLevel << +1 ReadLevel = InfoLevel UpdateLevel = InfoLevel )
View Source
const ( FileNameDateFormat = "20060102150405" FileOpt = os.O_RDWR | os.O_CREATE | os.O_APPEND WriterBufferInitSize = 4 * 1024 * 1024 WriterBufferLenLimit = 4 * 1024 * 1024 DefaultRollingInterval = 1 * time.Second RolledExtension = ".old" MaxReservedDays = 7 * 24 * time.Hour )
View Source
const ( InvalidLogLevel = "Invalid log level, only support [error, warn, debug, info, read, update, critical]" OpenLogFileFailed = "Failed to open log file" GetLogNumFailed = "Failed to get param num" TailLogFileFailed = "Failed to tail log file" InvaildLogNum = ", invalid num param, use default num" TooBigNum = ", param num is too big, use default max num" LossNum = ", can't find num param, use default num" GetLogPath = "/log/get" )
View Source
const ( // DefaultRollingSize Specifies at what size to roll the output log at // Units: byte DefaultRollingSize = 5 * 1024 * 1024 * 1024 DefaultMinRollingSize = 200 * 1024 * 1024 // DefaultHeadRoom The tolerance for the log space limit (in megabytes) DefaultHeadRoom = 50 * 1024 // DefaultHeadRatio The disk reserve space ratio DefaultHeadRatio = 0.2 )
View Source
const (
SetLogLevelPath = "/loglevel/set"
)
Variables ¶
View Source
var ( ErrLogFileName = "_error.log" WarnLogFileName = "_warn.log" InfoLogFileName = "_info.log" DebugLogFileName = "_debug.log" ReadLogFileName = "_read.log" UpdateLogFileName = "_write.log" CriticalLogFileName = "_critical.log" )
View Source
var LogDir string
Functions ¶
func LogCriticalf ¶
func LogCriticalf(format string, v ...interface{})
LogFatalf logs the fatal errors with specified format.
func LogDebugf ¶
func LogDebugf(format string, v ...interface{})
LogDebugf logs the debug information with specified format.
func LogErrorf ¶
func LogErrorf(format string, v ...interface{})
LogErrorf logs the errors with the specified format.
func LogFatalf ¶
func LogFatalf(format string, v ...interface{})
LogFatalf logs the fatal errors with specified format.
func LogInfof ¶
func LogInfof(format string, v ...interface{})
LogInfo indicates log the information with specific format. TODO explain
func LogWarnf ¶
func LogWarnf(format string, v ...interface{})
LogWarnf indicates the warnings with specific format.
func SetLogLevel ¶
func SetLogLevel(w http.ResponseWriter, r *http.Request)
Types ¶
type HTTPReply ¶
type HTTPReply struct { Code int32 `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` }
HTTPReply uniform response structure
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log defines the log struct.
type LogObject ¶
LogObject defines the log object.
func (*LogObject) SetRotation ¶
func (ob *LogObject) SetRotation()
type LogRotate ¶
type LogRotate struct {
// contains filtered or unexported fields
}
A log can be rotated by the size or time.
func (*LogRotate) SetHeadRoomMb ¶
SetHeadRoomMb sets the headroom in terms of MB.
func (*LogRotate) SetRollingSizeMb ¶
SetRollingSizeMb sets the rolling size in terms of MB.
type RolledFile ¶
func (RolledFile) Len ¶
func (f RolledFile) Len() int
func (RolledFile) Less ¶
func (f RolledFile) Less(i, j int) bool
func (RolledFile) Swap ¶
func (f RolledFile) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.