Documentation ¶
Index ¶
- Variables
- func IsDebug() bool
- func MustToConsoleAndFile(filepath string, flag int) io.Writer
- func MustToFile(filename string, flag int) io.Writer
- func ToConsole() io.Writer
- func ToConsoleAndFile(filepath string, flag int) (io.Writer, error)
- func ToFile(filename string, flag int) (io.Writer, error)
- type Arg
- type Level
- type Logger
Constants ¶
This section is empty.
Variables ¶
var ( // Default time format with nanosecond precision TimeFormat = "2006-01-02 15:04:05.999999999" // Console default time format with millisecond accuracy ConsoleTimeFormat = "15:04:05.000" )
Functions ¶
func IsDebug ¶ added in v0.2.4
func IsDebug() bool
IsDebug determines whether the current environment is `DEBUG` through the `DEBUG` variable in the current environment variables.
func MustToConsoleAndFile ¶ added in v0.2.4
MustToConsoleAndFile returns an `io.Writer` that can both output the log to a control or terminal emulator and save the log to a local file, which will panic if there is an error opening the file.
The `flag` parameter is passed to the `os.OpenFile` function. If flag < 0, it will be assigned the value `os.O_RDWR|os.O_CREATE|os.O_TRUNC`.
func MustToFile ¶ added in v0.2.4
MustToFile returns an `io.Writer` that saves the log to a local file and will panic if there is an error opening the file.
The `flag` parameter is passed to the `os.OpenFile` function. If flag < 0, it will be assigned the value `os.O_RDWR|os.O_CREATE|os.O_TRUNC`.
func ToConsole ¶ added in v0.2.4
ToConsole returns an `io.Writer` that outputs the log to the console or terminal emulator or an `error`.
func ToConsoleAndFile ¶ added in v0.2.4
ToConsoleAndFile returns an `io.Writer` that can both output the log to a control or terminal emulator and save the log to a local file, or an `error`.
The `flag` parameter is passed to the `os.OpenFile` function. If flag < 0, it will be assigned the value `os.O_RDWR|os.O_CREATE|os.O_TRUNC`.
Types ¶
type Arg ¶ added in v0.2.4
type Arg struct { Key string Value interface{} }
Arg records the parameters required in the log as key-value pairs, the key is of type `string`, and the value can be of any type.
type Logger ¶ added in v0.2.4
Logger records a `zerolog.Logger` pointer and uses this pointer to implement all logging methods
func (*Logger) Fatal ¶ added in v0.2.4
Fatal logs a `FATAL` message with some `Arg`s, and calls `os.Exit(1)` to exit the application.