Documentation ¶
Index ¶
- Constants
- Variables
- func Format(suffix bool, suffixInfo string, args ...interface{}) string
- func GetCurrentTime() *timestamp.Timestamp
- func GetDatetime() string
- func GetInnerIp() string
- func InitContext()
- func InitLog() error
- func MD5Encrypt(data string) string
- func ToDuration(d *duration.Duration) time.Duration
- func ToTime(ts *timestamp.Timestamp) time.Time
- func ToTimeStamp(t time.Time) *timestamp.Timestamp
- type Logger
- func (this *Logger) CheckLevel(logType string) bool
- func (this *Logger) Debug(args ...interface{})
- func (this *Logger) Error(args ...interface{})
- func (this *Logger) SetLevel(l int)
- func (this *Logger) Trace(args ...interface{})
- func (this *Logger) Warn(args ...interface{})
- func (this *Logger) Write(filename string, suffix bool, args ...interface{})
- type LoggerBuffer
- type LoggerInfo
- func (this *LoggerInfo) CreateFile() error
- func (this *LoggerInfo) FileSize() (int64, error)
- func (this *LoggerInfo) FlushBufferQueue()
- func (this *LoggerInfo) LoggerBackup(hour time.Time)
- func (this *LoggerInfo) NeedSplit() (split bool, backup bool)
- func (this *LoggerInfo) Write(content string)
- func (this *LoggerInfo) WriteBufferToQueue()
Constants ¶
View Source
const ( DATEFORMAT = "2006-01-02" HOURFORMAT = "2006010215" )
View Source
const ( KB int64 = 1 << (iota * 10) MB GB TB )
Variables ¶
View Source
var ( // Context 全局 Context Context context.Context // CancelFunc 全局 Context 取消方法 CancelFunc context.CancelFunc )
View Source
var (
GraceNet = gracenet.Net{}
)
Functions ¶
func GetDatetime ¶
func GetDatetime() string
func GetInnerIp ¶
func GetInnerIp() string
func ToDuration ¶
ToDuration 转换 GRPC Duration 为 time.Duration
Types ¶
type Logger ¶
* 默认文件包括debug/error/trace/warn
var ( // Log 全局 Log 对象 Log *Logger )
func (*Logger) CheckLevel ¶
type LoggerBuffer ¶
type LoggerBuffer struct {
// contains filtered or unexported fields
}
func NewLoggerBuffer ¶
func NewLoggerBuffer() *LoggerBuffer
func (*LoggerBuffer) WriteBuffer ¶
func (this *LoggerBuffer) WriteBuffer(bufferQueue chan LoggerBuffer)
func (*LoggerBuffer) WriteString ¶
func (this *LoggerBuffer) WriteString(str string)
type LoggerInfo ¶
type LoggerInfo struct {
// contains filtered or unexported fields
}
func NewLoggerInfo ¶
func NewLoggerInfo(filename, level string) (*LoggerInfo, error)
func (*LoggerInfo) FileSize ¶
func (this *LoggerInfo) FileSize() (int64, error)
* 获取文件大小,如果文件不存在则重新创建文件 * 则文件指针指向错误,重新open一下文件 * 如果有其他的错误,此处无法处理,只能是丢掉部分日志内容
func (*LoggerInfo) FlushBufferQueue ¶
func (this *LoggerInfo) FlushBufferQueue()
* buffer中的数据flush到硬盘
func (*LoggerInfo) LoggerBackup ¶
func (this *LoggerInfo) LoggerBackup(hour time.Time)
* 错误日志备份 * backupDir 待备份的目录 * os中没有mv的函数,只能先rename,后remove * backupDir -> /data/messenger/servers/log/saver/trace/2014-09-10/*.log
func (*LoggerInfo) NeedSplit ¶
func (this *LoggerInfo) NeedSplit() (split bool, backup bool)
* 判断文件是否需要切分
func (*LoggerInfo) Write ¶
func (this *LoggerInfo) Write(content string)
func (*LoggerInfo) WriteBufferToQueue ¶
func (this *LoggerInfo) WriteBufferToQueue()
只有该函数goroutine对map操作,map没有加锁
Click to show internal directories.
Click to hide internal directories.