Documentation ¶
Overview ¶
*************************************************************************** MIT License
Copyright (c) 2022 yjhi ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************
Index ¶
- Constants
- Variables
- func AppendAll(file string, content ...string) error
- func FormatLogs(format string, content ...string) string
- func GetLevelName(level int8) string
- func GetLevelValue(name string) int8
- func LogDuration(s time.Duration) string
- func LogFloat(s float64) string
- func LogFormat(content ...string) string
- func LogFormatV(content ...interface{}) string
- func LogInt(s int) string
- func LogValue(s interface{}) string
- func WriteAll(file string, content ...string) error
- type LogConfig
- type LogHandler
- type LogInterface
- type LogUtils
- func Build(path string, name string, tail string, tp int8) *LogUtils
- func BuildDayLogUtils(path string, name string, tail string) *LogUtils
- func BuildLogWithConfig(config LogConfig) *LogUtils
- func BuildMonthLogUtils(path string, name string, tail string) *LogUtils
- func BuildSingleLogUtils(path string, name string, tail string) *LogUtils
- func (l *LogUtils) Close()
- func (l *LogUtils) Critical(content string)
- func (l *LogUtils) Debug(content string)
- func (l *LogUtils) Error(content string)
- func (l *LogUtils) Flush()
- func (l *LogUtils) Info(content string)
- func (l *LogUtils) Log(level int8, content string)
- func (l *LogUtils) LogF(level int8, format string, content ...string) *LogUtils
- func (l *LogUtils) LogFileName() string
- func (l *LogUtils) LogJson(level int8, content interface{})
- func (l *LogUtils) LogV(level int8, content ...interface{})
- func (l *LogUtils) Logs(level int8, content ...string)
- func (l *LogUtils) Use(fun LogHandler)
- func (l *LogUtils) Warn(content string)
- func (l *LogUtils) WithLevel(level int8) *LogUtils
- func (l *LogUtils) Write(p []byte) (int, error)
- func (l *LogUtils) WriteContent(content string) *LogUtils
- func (l *LogUtils) WriteLevel(level int8) *LogUtils
- type MultLog
- func (l *MultLog) Close()
- func (l *MultLog) Critical(content string)
- func (l *MultLog) Debug(content string)
- func (l *MultLog) Error(content string)
- func (l *MultLog) Flush()
- func (l *MultLog) Info(content string)
- func (l *MultLog) Log(level int8, content string)
- func (l *MultLog) LogF(level int8, format string, content ...string) *MultLog
- func (l *MultLog) LogJson(level int8, content interface{})
- func (l *MultLog) LogV(level int8, content ...interface{})
- func (l *MultLog) Logs(level int8, content ...string)
- func (l *MultLog) Use(fun LogHandler)
- func (l *MultLog) Warn(content string)
- func (l *MultLog) WithLevel(level int8) *MultLog
- func (l *MultLog) WriteContent(level int8, content string) *MultLog
- func (l *MultLog) WriteLevel(level int8) *MultLog
- func (l *MultLog) Writer(level int8) io.Writer
Constants ¶
const ( LOG_DAY int8 = 1 + iota LOG_MONTH LOG_SINGLE )
const ( CRITICAL int8 = 1 + iota ERROR WARN INFO DEBUG )
Variables ¶
var DefLogLevelName string = "INFO"
var DefLogLevelValue int8 = INFO
var LogLevelName map[int8]string = map[int8]string{
1: "CRITICAL",
2: "ERROR",
3: "WARN",
4: "INFO",
5: "DEBUG",
}
var LogLevelValue map[string]int8 = map[string]int8{
"CRITICAL": 1,
"ERROR": 2,
"WARN": 3,
"INFO": 4,
"DEBUG": 5,
}
Functions ¶
func FormatLogs ¶
format log format {0} {1} {2}
func GetLevelName ¶
func GetLevelValue ¶
func LogDuration ¶
func LogFormatV ¶
func LogFormatV(content ...interface{}) string
Types ¶
type LogConfig ¶
type LogConfig struct { LogPath string LogName string LogTail string Level int8 Buffer bool FlushCount int LogType int8 Handler LogHandler }
func (LogConfig) SetHandler ¶
func (b LogConfig) SetHandler(handler LogHandler)
type LogHandler ¶
type LogInterface ¶
type LogInterface interface { Use(fun LogHandler) Close() LogFileName() string Debug(content string) Info(content string) Warn(content string) Error(content string) Critical(content string) Log(level int8, content string) Logs(level int8, content ...string) LogJson(level int8, content interface{}) LogV(level int8, content ...interface{}) }
type LogUtils ¶
LogUtils add by yjh 211123
func BuildDayLogUtils ¶
build day log
func BuildLogWithConfig ¶
func BuildMonthLogUtils ¶
build month log
func BuildSingleLogUtils ¶
build single log
func (*LogUtils) LogFileName ¶
func (*LogUtils) WriteContent ¶
func (*LogUtils) WriteLevel ¶
type MultLog ¶
type MultLog struct { LogConfig // contains filtered or unexported fields }