jlog

package module
v0.0.0-...-daa74e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

*************************************************************************** MIT License

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

View Source
const (
	LOG_DAY int8 = 1 + iota
	LOG_MONTH
	LOG_SINGLE
)
View Source
const (
	CRITICAL int8 = 1 + iota
	ERROR
	WARN
	INFO
	DEBUG
)

Variables

View Source
var DefLogLevelName string = "INFO"
View Source
var DefLogLevelValue int8 = INFO
View Source
var LogLevelName map[int8]string = map[int8]string{
	1: "CRITICAL",
	2: "ERROR",
	3: "WARN",
	4: "INFO",
	5: "DEBUG",
}
View Source
var LogLevelValue map[string]int8 = map[string]int8{
	"CRITICAL": 1,
	"ERROR":    2,
	"WARN":     3,
	"INFO":     4,
	"DEBUG":    5,
}

Functions

func AppendAll

func AppendAll(file string, content ...string) error

func FormatLogs

func FormatLogs(format string, content ...string) string

format log format {0} {1} {2}

func GetLevelName

func GetLevelName(level int8) string

func GetLevelValue

func GetLevelValue(name string) int8

func LogDuration

func LogDuration(s time.Duration) string

func LogFloat

func LogFloat(s float64) string

func LogFormat

func LogFormat(content ...string) string

func LogFormatV

func LogFormatV(content ...interface{}) string

func LogInt

func LogInt(s int) string

func LogValue

func LogValue(s interface{}) string

func WriteAll

func WriteAll(file string, content ...string) error

Types

type LogConfig

type LogConfig struct {
	LogPath string
	LogName string
	LogTail string

	Level      int8
	Buffer     bool
	FlushCount int

	LogType int8

	Handler LogHandler
}

func (LogConfig) SetBuffer

func (b LogConfig) SetBuffer(buffer bool, flush int)

func (LogConfig) SetHandler

func (b LogConfig) SetHandler(handler LogHandler)

func (LogConfig) SetLevel

func (b LogConfig) SetLevel(level int8)

type LogHandler

type LogHandler func(tm string, level string, message string)

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

type LogUtils struct {
	LogConfig
	LastError error
	// contains filtered or unexported fields
}

LogUtils add by yjh 211123

func Build

func Build(path string, name string, tail string, tp int8) *LogUtils

func BuildDayLogUtils

func BuildDayLogUtils(path string, name string, tail string) *LogUtils

build day log

func BuildLogWithConfig

func BuildLogWithConfig(config LogConfig) *LogUtils

func BuildMonthLogUtils

func BuildMonthLogUtils(path string, name string, tail string) *LogUtils

build month log

func BuildSingleLogUtils

func BuildSingleLogUtils(path string, name string, tail string) *LogUtils

build single log

func (*LogUtils) Close

func (l *LogUtils) Close()

close file

func (*LogUtils) Critical

func (l *LogUtils) Critical(content string)

critical

func (*LogUtils) Debug

func (l *LogUtils) Debug(content string)

debug

func (*LogUtils) Error

func (l *LogUtils) Error(content string)

error

func (*LogUtils) Flush

func (l *LogUtils) Flush()

func (*LogUtils) Info

func (l *LogUtils) Info(content string)

info

func (*LogUtils) Log

func (l *LogUtils) Log(level int8, content string)

log

func (*LogUtils) LogF

func (l *LogUtils) LogF(level int8, format string, content ...string) *LogUtils

/format {0} {1} {2}

func (*LogUtils) LogFileName

func (l *LogUtils) LogFileName() string

func (*LogUtils) LogJson

func (l *LogUtils) LogJson(level int8, content interface{})

func (*LogUtils) LogV

func (l *LogUtils) LogV(level int8, content ...interface{})

func (*LogUtils) Logs

func (l *LogUtils) Logs(level int8, content ...string)

logs

func (*LogUtils) Use

func (l *LogUtils) Use(fun LogHandler)

hook

func (*LogUtils) Warn

func (l *LogUtils) Warn(content string)

warn

func (*LogUtils) WithLevel

func (l *LogUtils) WithLevel(level int8) *LogUtils

func (*LogUtils) Write

func (l *LogUtils) Write(p []byte) (int, error)

func (*LogUtils) WriteContent

func (l *LogUtils) WriteContent(content string) *LogUtils

func (*LogUtils) WriteLevel

func (l *LogUtils) WriteLevel(level int8) *LogUtils

type MultLog

type MultLog struct {
	LogConfig
	// contains filtered or unexported fields
}

func BuildMultLog

func BuildMultLog(path string, name string, tail string, level int8) *MultLog

func BuildMultWithConfig

func BuildMultWithConfig(config LogConfig) *MultLog

func (*MultLog) Close

func (l *MultLog) Close()

close file

func (*MultLog) Critical

func (l *MultLog) Critical(content string)

critical

func (*MultLog) Debug

func (l *MultLog) Debug(content string)

debug

func (*MultLog) Error

func (l *MultLog) Error(content string)

error

func (*MultLog) Flush

func (l *MultLog) Flush()

func (*MultLog) Info

func (l *MultLog) Info(content string)

info

func (*MultLog) Log

func (l *MultLog) Log(level int8, content string)

log

func (*MultLog) LogF

func (l *MultLog) LogF(level int8, format string, content ...string) *MultLog

format {0} {1} {2}

func (*MultLog) LogJson

func (l *MultLog) LogJson(level int8, content interface{})

func (*MultLog) LogV

func (l *MultLog) LogV(level int8, content ...interface{})

func (*MultLog) Logs

func (l *MultLog) Logs(level int8, content ...string)

logs

func (*MultLog) Use

func (l *MultLog) Use(fun LogHandler)

hook

func (*MultLog) Warn

func (l *MultLog) Warn(content string)

warn

func (*MultLog) WithLevel

func (l *MultLog) WithLevel(level int8) *MultLog

func (*MultLog) WriteContent

func (l *MultLog) WriteContent(level int8, content string) *MultLog

func (*MultLog) WriteLevel

func (l *MultLog) WriteLevel(level int8) *MultLog

func (*MultLog) Writer

func (l *MultLog) Writer(level int8) io.Writer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL