zlog

package
v1.7.14 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 22 Imported by: 27

Documentation

Overview

Package zlog provide daily log service

Index

Constants

View Source
const (
	BitDate         int                                 = 1 << iota // Date marker  2019/01/23
	BitTime                                                         // Time Label Bit  01:23:12
	BitMicroSeconds                                                 // Microsecond label bit 01:23:12.111222
	BitLongFile                                                     // Full file name, example: /home/go/src/github.com/sohaha/zlsgo/doc.go
	BitShortFile                                                    // Final File name   doc.go
	BitLevel                                                        // Current log level
	BitStdFlag      = BitDate | BitTime                             // Standard header log format
	BitDefault      = BitLevel | BitShortFile | BitTime             // Default log header format
	// LogMaxBuf LogMaxBuf
	LogMaxBuf = 1024 * 1024
)

log header information tag bit, using bitmap mode

View Source
const (
	LogFatal = iota
	LogPanic
	LogTrack
	LogError
	LogWarn
	LogTips
	LogSuccess
	LogInfo
	LogDebug
	LogDump
	LogNot = -1
)

log level

Variables

View Source
var DisableColor = false

DisableColor DisableColor

View Source
var Levels = []string{
	"[FATAL]",
	"[PANIC]",
	"[TRACK]",
	"[ERROR]",
	"[WARN] ",
	"[TIPS] ",
	"[SUCCE]",
	"[INFO] ",
	"[DEBUG]",
	"[DUMP] ",
}
View Source
var LogMaxDurationDate = 15

Functions

func AddFlag deprecated

func AddFlag(flag int)

Deprecated: please use SetDefault AddFlag Set flag Tags

func CleanLog

func CleanLog(log *Logger)

CleanLog CleanLog

func ColorBackgroundWrap

func ColorBackgroundWrap(color Color, backgroundColor Color, text string) string

ColorBackgroundWrap ColorBackgroundWrap

func ColorTextWrap

func ColorTextWrap(color Color, text string) string

ColorTextWrap ColorTextWrap

func Debug

func Debug(v ...interface{})

Debug Debug

func Debugf

func Debugf(format string, v ...interface{})

Debugf Debugf

func DisableConsoleColor deprecated

func DisableConsoleColor()

Deprecated: please use SetDefault DisableConsoleColor DisableConsoleColor

func Discard added in v0.1.33

func Discard()

Discard Discard

func Dump added in v0.0.19

func Dump(v ...interface{})

Dump Dump

func Error

func Error(v ...interface{})

Error Error

func Errorf

func Errorf(format string, v ...interface{})

Errorf Errorf

func Fatal

func Fatal(v ...interface{})

Fatal Fatal

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf Fatalf

func ForceConsoleColor deprecated

func ForceConsoleColor()

Deprecated: please use SetDefault ForceConsoleColor ForceConsoleColor

func GetAllColorText

func GetAllColorText() map[string]Color

GetAllColorText GetAllColorText

func GetFlags deprecated

func GetFlags() int

Deprecated: please use SetDefault GetFlags Get the tag bits

func GetLogLevel deprecated

func GetLogLevel() int

Deprecated: please use SetDefault GetLogLevel Setting log display level

func Info

func Info(v ...interface{})

Info Info

func Infof

func Infof(format string, v ...interface{})

Infof Infof

func IsSupportColor

func IsSupportColor() bool

IsSupportColor IsSupportColor

func OpTextWrap

func OpTextWrap(op Op, text string) string

OpTextWrap OpTextWrap

func OutAllColor

func OutAllColor()

OutAllColor OutAllColor

func Panic

func Panic(v ...interface{})

Panic panic

func Panicf

func Panicf(format string, v ...interface{})

Panicf Panicf

func Printf

func Printf(format string, v ...interface{})

Printf Printf

func Println

func Println(v ...interface{})

Println Println

func ResetFlags deprecated

func ResetFlags(flag int)

Deprecated: please use SetDefault ResetFlags Setting Markup Bits

func SetDefault added in v1.7.12

func SetDefault(l *Logger)

SetDefault set default logger

func SetFile deprecated added in v0.1.53

func SetFile(filepath string, archive ...bool)

Deprecated: please use SetDefault SetFile Setting up log files

func SetLogLevel deprecated

func SetLogLevel(level int)

Deprecated: please use SetDefault SetLogLevel Setting log display level

func SetPrefix deprecated

func SetPrefix(prefix string)

Deprecated: please use SetDefault SetPrefix Setting log header prefix

func SetSaveFile deprecated added in v0.1.53

func SetSaveFile(filepath string, archive ...bool)

Deprecated: please use SetDefault SetSaveFile SetSaveFile

func Stack

func Stack(v interface{})

Stack Stack

func Success

func Success(v ...interface{})

Success Success

func Successf

func Successf(format string, v ...interface{})

Successf Successf

func Tips added in v1.1.0

func Tips(v ...interface{})

Tips Tips

func Tipsf added in v1.1.0

func Tipsf(format string, v ...interface{})

Tipsf Tipsf

func Track

func Track(v string, i ...int)

Track Track

func TrimAnsi added in v1.7.10

func TrimAnsi(str string) string

func Warn

func Warn(v ...interface{})

Warn Warn

func Warnf

func Warnf(format string, v ...interface{})

Warnf Warnf

Types

type Color

type Color int

Color Color

const (
	// ColorBlack black
	ColorBlack Color = iota + 30
	// ColorRed gules
	ColorRed
	// ColorGreen green
	ColorGreen
	// ColorYellow yellow
	ColorYellow
	// ColorBlue blue
	ColorBlue
	// ColorMagenta magenta
	ColorMagenta
	// ColorCyan cyan
	ColorCyan
	// ColorWhite white
	ColorWhite
)
const (
	// ColorLightGrey light grey
	ColorLightGrey Color = iota + 90
	// ColorLightRed light red
	ColorLightRed
	// ColorLightGreen light green
	ColorLightGreen
	// ColorLightYellow light yellow
	ColorLightYellow
	// ColorLightBlue light blue
	ColorLightBlue
	// ColorLightMagenta light magenta
	ColorLightMagenta
	// ColorLightCyan lightcyan
	ColorLightCyan
	// ColorLightWhite light white
	ColorLightWhite
	// ColorDefault ColorDefault
	ColorDefault = 49
)

type Format added in v0.0.19

type Format int

Format Format

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger logger struct

func New

func New(moduleName ...string) *Logger

New Initialize a log object

func NewZLog

func NewZLog(out io.Writer, prefix string, flag int, level int, color bool, calldDepth int) *Logger

NewZLog Create log

func (*Logger) AddFlag

func (log *Logger) AddFlag(flag int)

AddFlag Set flag Tags

func (*Logger) CloseFile

func (log *Logger) CloseFile()

func (*Logger) ColorBackgroundWrap

func (log *Logger) ColorBackgroundWrap(color Color, backgroundColor Color, text string) string

ColorBackgroundWrap ColorBackgroundWrap

func (*Logger) ColorTextWrap

func (log *Logger) ColorTextWrap(color Color, text string) string

ColorTextWrap ColorTextWrap

func (*Logger) Debug

func (log *Logger) Debug(v ...interface{})

Debug Debug

func (*Logger) Debugf

func (log *Logger) Debugf(format string, v ...interface{})

Debugf Debugf

func (*Logger) DisableConsoleColor

func (log *Logger) DisableConsoleColor()

DisableConsoleColor DisableConsoleColor

func (*Logger) Discard added in v0.1.33

func (log *Logger) Discard()

func (*Logger) Dump added in v0.0.19

func (log *Logger) Dump(v ...interface{})

Dump pretty print format

func (*Logger) Error

func (log *Logger) Error(v ...interface{})

Error output Error

func (*Logger) Errorf

func (log *Logger) Errorf(format string, v ...interface{})

Errorf output Error

func (*Logger) Fatal

func (log *Logger) Fatal(v ...interface{})

Fatal output Fatal

func (*Logger) Fatalf

func (log *Logger) Fatalf(format string, v ...interface{})

Fatalf output Fatal

func (*Logger) ForceConsoleColor

func (log *Logger) ForceConsoleColor()

ForceConsoleColor ForceConsoleColor

func (*Logger) GetFlags

func (log *Logger) GetFlags() int

GetFlags Get the current log bitmap tag

func (*Logger) GetLogLevel

func (log *Logger) GetLogLevel() int

GetLogLevel Get log display level

func (*Logger) GetPrefix added in v1.1.0

func (log *Logger) GetPrefix() string

func (*Logger) Info

func (log *Logger) Info(v ...interface{})

Info output Info

func (*Logger) Infof

func (log *Logger) Infof(format string, v ...interface{})

Infof output Info

func (*Logger) OpTextWrap

func (log *Logger) OpTextWrap(color Op, text string) string

OpTextWrap OpTextWrap

func (*Logger) Panic

func (log *Logger) Panic(v ...interface{})

Panic output panic

func (*Logger) Panicf

func (log *Logger) Panicf(format string, v ...interface{})

Panicf output Panic

func (*Logger) Printf

func (log *Logger) Printf(format string, v ...interface{})

Printf formats according to a format specifier and writes to standard output

func (*Logger) Println

func (log *Logger) Println(v ...interface{})

Println Println

func (*Logger) ResetFlags

func (log *Logger) ResetFlags(flag int)

ResetFlags Reset the GetFlags bitMap tag bit in the log

func (*Logger) SetFile added in v0.1.33

func (log *Logger) SetFile(filepath string, archive ...bool)

SetFile Setting log file output

func (*Logger) SetIgnoreLog added in v1.6.0

func (log *Logger) SetIgnoreLog(logs ...string)

func (*Logger) SetLogLevel

func (log *Logger) SetLogLevel(level int)

SetLogLevel Setting log display level

func (*Logger) SetPrefix

func (log *Logger) SetPrefix(prefix string)

SetPrefix Setting log prefix

func (*Logger) SetSaveFile added in v0.1.33

func (log *Logger) SetSaveFile(filepath string, archive ...bool)

func (*Logger) Stack

func (log *Logger) Stack(v interface{})

Stack output Stack

func (*Logger) Success

func (log *Logger) Success(v ...interface{})

Success output Success

func (*Logger) Successf

func (log *Logger) Successf(format string, v ...interface{})

Successf output Success

func (*Logger) Tips added in v1.1.0

func (log *Logger) Tips(v ...interface{})

Tips output Tips

func (*Logger) Tipsf added in v1.1.0

func (log *Logger) Tipsf(format string, v ...interface{})

Tipsf output Tips

func (*Logger) Track

func (log *Logger) Track(v string, i ...int)

Track output Track

func (*Logger) Warn

func (log *Logger) Warn(v ...interface{})

Warn output Warn

func (*Logger) Warnf

func (log *Logger) Warnf(format string, v ...interface{})

Warnf output Warn

func (*Logger) Write added in v1.6.0

func (log *Logger) Write(b []byte) (n int, err error)

func (*Logger) WriteBefore added in v1.7.10

func (log *Logger) WriteBefore(fn ...func(level int, log string) bool)

func (*Logger) Writer

func (log *Logger) Writer() logWriter

type Op

type Op int

Op Op

const (
	// OpReset Reset All Settings
	OpReset Op = iota
	// OpBold Bold
	OpBold
	// OpFuzzy Fuzzy (not all terminal emulators support it)
	OpFuzzy
	// OpItalic Italic (not all terminal emulators support it)
	OpItalic
	// OpUnderscore Underline
	OpUnderscore
	// OpBlink Twinkle
	OpBlink
	// OpFastBlink Fast scintillation (not widely supported)
	OpFastBlink
	// OpReverse Reversed Exchange Background and Foreground Colors
	OpReverse
	// OpConcealed Concealed
	OpConcealed
	// OpStrikethrough Deleted lines (not widely supported)
	OpStrikethrough
)

Jump to

Keyboard shortcuts

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