hlogger

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 11 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentDay = ""

CurrentDay 指明当前日志时间

View Source
var DebugMode = false

DebugMode indicates if debug information should be printed or not

If the environment variable called DEBUG is set to 1, this will default to true. In all other cases, debug mode is false by default.

View Source
var DefaultTimeFormat = "2006-01-02 15:04:05"

DefaultTimeFormat is the default format to use for the timestamps

View Source
var DefaultTimeZone = "Asia/Shanghai"

DefaultTimeZone 缺省时区

View Source
var FileOutputName = ""

FileOutputName 指明日志是否输入指定文件,当为空时,表示从console输出

View Source
var OsExit = os.Exit

OsExit is the function to exit the app when a fatal error happens

View Source
var PrintColors = false

PrintColors indicates if the messages should be printed in color or not

View Source
var PrintTimestamp = false

PrintTimestamp indicates if the log messages should include a timestamp or not

View Source
var RotateFile = false

RotateFile 指明日志文件是否根据日期生成不同的日志文件

View Source
var Stderr io.Writer = os.Stderr

Stderr is the writer to where the stderr messages should be written (defaults to os.Stderr)

View Source
var Stdout io.Writer = os.Stdout

Stdout is the writer to where the stdout messages should be written (defaults to os.Stdout)

View Source
var TestingTimeFormat = "test"

TestingTimeFormat is the format to use for the timestamps during testing

View Source
var TimeFormat = DefaultTimeFormat

TimeFormat is the format to use for the timestamps

View Source
var TimeZone *time.Location

TimeZone indicates in which timezone the time should be formatted

Functions

func CheckError

func CheckError(err error)

CheckError checks if the error is not nil and if that's the case, it will print a fatal message and exits the program with exit code 1.

If DebugMode is enabled a stack trace will also be printed to stderr

func Debug

func Debug(args ...interface{})

Debug prints a debug message

Only shown if DebugMode is set to true

func DebugDump

func DebugDump(arg interface{}, prefix string)

DebugDump dumps the argument as a debug message with an optional prefix

func DebugSeparator

func DebugSeparator(args ...interface{})

DebugSeparator prints a debug separator

Only shown if DebugMode is set to true

func Debugf

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

Debugf prints a debug message with a format and arguments

Only shown if DebugMode is set to true

func Error

func Error(args ...interface{})

Error prints an error message to stderr

func ErrorDump

func ErrorDump(arg interface{}, prefix string)

ErrorDump dumps the argument as an err message with an optional prefix to stderr

func ErrorSeparator

func ErrorSeparator(args ...interface{})

ErrorSeparator prints an error separator

func Errorf

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

Errorf prints an error message with a format and arguments

func Fatal

func Fatal(args ...interface{})

Fatal logs a fatal error message to stdout and exits the program with exit code 1

func Fatalf

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

Fatalf prints a fatal message with a format and arguments

func FormattedStackTrace

func FormattedStackTrace(err error) string

FormattedStackTrace returns a formatted stacktrace for err

func Info

func Info(args ...interface{})

Info prints an info message

func InfoDump

func InfoDump(arg interface{}, prefix string)

InfoDump dumps the argument as an info message with an optional prefix

func InfoSeparator

func InfoSeparator(args ...interface{})

InfoSeparator prints an info separator

func Infof

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

Infof prints an info message with a format and arguments

func SetFileOutput

func SetFileOutput(pathName string, rotate bool)

func StackTrace

func StackTrace(err error)

StackTrace prints an error message with the stacktrace of err to stderr

func Warn

func Warn(args ...interface{})

Warn prints an warning message

func WarnDump

func WarnDump(arg interface{}, prefix string)

WarnDump dumps the argument as a warning message with an optional prefix

func WarnSeparator

func WarnSeparator(args ...interface{})

WarnSeparator prints a warning separator

func Warnf

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

Warnf prints a warning message with a format and arguments

Types

This section is empty.

Jump to

Keyboard shortcuts

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