Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Init(opts ...Option) error
- func Log(level Level, v ...interface{})
- func Logf(level Level, format string, v ...interface{})
- func String() string
- func Trace(args ...interface{})
- func Tracef(template string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type Level
- type Logger
- type Mode
- type Option
- func OutputFilePath(filename string) Option
- func OutputRootPath(rootPath string) Option
- func ReportCaller() Option
- func SetOption(k, v interface{}) Option
- func SplitLogByHour() Option
- func UseAsDefault() Option
- func WithDevelopmentMode() Option
- func WithExitFunc(exit func(int)) Option
- func WithHooks(hooks []zerolog.Hook) Option
- func WithProductionMode() Option
- func WithTimeFormat(timeFormat string) Option
- type Options
Constants ¶
View Source
const FORMAT = "20060102"
FORMAT Date
Variables ¶
View Source
var ( // LevelTraceValue is the value used for the trace level field. LevelTraceValue = "trace" // LevelDebugValue is the value used for the debug level field. LevelDebugValue = "debug" // LevelInfoValue is the value used for the info level field. LevelInfoValue = "info" // LevelWarnValue is the value used for the warn level field. LevelWarnValue = "warn" // LevelErrorValue is the value used for the error level field. LevelErrorValue = "error" // LevelFatalValue is the value used for the fatal level field. LevelFatalValue = "fatal" // LevelPanicValue is the value used for the panic level field. LevelPanicValue = "panic" )
Functions ¶
Types ¶
type Level ¶
type Level int8
Level defines log levels.
const ( // DebugLevel defines debug log level. DebugLevel Level = iota // InfoLevel defines info log level. InfoLevel // WarnLevel defines warn log level. WarnLevel // ErrorLevel defines error log level. ErrorLevel // FatalLevel defines fatal log level. FatalLevel // PanicLevel defines panic log level. PanicLevel // NoLevel defines an absent log level. NoLevel // Disabled disables the logger. Disabled // TraceLevel defines trace log level. TraceLevel Level = -1 )
type Logger ¶
type Logger interface { // Init initialises options Init(options ...Option) error // The Logger options Options() Options // Fields set fields to always be logged Fields(fields map[string]interface{}) Logger // Log writes a log entry Log(level Level, v ...interface{}) // Logf writes a formatted log entry Logf(level Level, format string, v ...interface{}) // String returns the name of logger String() string }
Logger is a generic logging interface
type Option ¶
type Option func(*Options)
func OutputFilePath ¶
func OutputRootPath ¶
func ReportCaller ¶
func ReportCaller() Option
func SplitLogByHour ¶
func SplitLogByHour() Option
func UseAsDefault ¶
func UseAsDefault() Option
func WithDevelopmentMode ¶
func WithDevelopmentMode() Option
func WithExitFunc ¶
func WithProductionMode ¶
func WithProductionMode() Option
func WithTimeFormat ¶
type Options ¶
type Options struct { // It's common to set this to a file, or leave it default which is `os.Stderr` Out io.Writer // The logging level the logger should log at. default is `InfoLevel` Level Level // fields to always be logged Fields map[string]interface{} Context context.Context // Flag for whether to log caller info (off by default) ReportCaller bool // Use this logger as system wide default logger (off by default) UseAsDefault bool // zerolog hooks Hooks []zerolog.Hook // TimeFormat is one of time.RFC3339, time.RFC3339Nano, time.* TimeFormat string // Runtime mode. (Production by default) Mode Mode // Exit Function to call when FatalLevel log ExitFunc func(int) // Output file name // If set, output to a file OutputFilePath string // Output root path OutputRootPath string // Split the log by the hour SplitLogByHour bool }
Click to show internal directories.
Click to hide internal directories.