logger

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package logger logger base on zap

The differents between development logger add production logger is that development logger include caller. Thus, a production log should like {"level":"ERROR","time":"2019-07-18T03:09:46.098+0800","message":"cert and key can not be empty, failed to listen https port"} a development log should like {"level":"ERROR","time":"2019-07-18T03:12:45.599+0800","caller":"logger/logger.go:129","message":"cert and key can not be empty, failed to listen https port"}

Development logger output through log file and console Production logger output just log file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DPanic

func DPanic(msg string, args ...zapcore.Field)

DPanic logs a message at DPanicLevel. The message includes any fields passed at the log site. DPanic means "development panic"

func DPanicf

func DPanicf(template string, args ...interface{})

DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)

func Error

func Error(msg string, args ...zapcore.Field)

Error logs a message at ErrorLevel. The message includes any fields passed at the log site.

func Errorf

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

Errorf uses fmt.Sprintf to log a templated message.

func Fatal

func Fatal(msg string, args ...zapcore.Field)

Fatal logs a message at FatalLevel. The message includes any fields passed at the log site.

func Fatalf

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

Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func Info

func Info(msg string, fields ...zapcore.Field)

Info logs a message at InfoLevel. The message includes any fields passed at the log site.

func Infof

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

Infof uses fmt.Sprintf to log a templated message.

func InitDevelopmentLogger

func InitDevelopmentLogger() *zap.Logger

InitDevelopmentLogger init the logger for development environment

func InitLogger

func InitLogger(runmode string)

InitLogger init zap logger

func InitProductionLogger

func InitProductionLogger() *zap.Logger

InitProductionLogger init the logger for production environment

func Panic

func Panic(msg string, args ...zapcore.Field)

Panic logs a message at PanicLevel. The message includes any fields passed at the log site.

func Panicf

func Panicf(template string, args ...interface{})

Panicf uses fmt.Sprintf to log a templated message, then panics.

func Warn

func Warn(msg string, args ...zapcore.Field)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site.

func Warnf

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

Warnf uses fmt.Sprintf to log a templated message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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