logging

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides logging functionality for gnet server, it sets up a default logger (powered by go.uber.org/zap) which is about to be used by gnet server, it also allows users to replace the default logger with their customized logger by just implementing the `Logger` interface and assign it to the functional option `Options.Logger`, pass it to `gnet.Serve` method.

There are two logging modes in zap, instantiated by either NewProduction() or NewDevelopment(), the former builds a sensible production Logger that writes InfoLevel and above logs to standard error as JSON, it's a shortcut for NewProductionConfig().Build(...Option); the latter builds a development Logger that writes DebugLevel and above logs to standard error in a human-friendly format, it's a shortcut for NewDevelopmentConfig().Build(...Option).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup()

Cleanup does something windup for logger, like closing, flushing, etc.

func Debugf

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

Debugf logs messages at DEBUG level.

func Errorf

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

Errorf logs messages at ERROR level.

func Fatalf

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

Fatalf logs messages at FATAL level.

func Infof

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

Infof logs messages at INFO level.

func Init

func Init(logLevel zapcore.Level)

Init initializes the inside default logger of client.

func Level

func Level() zapcore.Level

Level returns the logging level.

func LogErr

func LogErr(err error)

LogErr prints err if it's not nil.

func SetupLogger

func SetupLogger(logger Logger, logLevel zapcore.Level)

SetupLogger setups the logger by the Logger interface.

func SetupLoggerWithPath

func SetupLoggerWithPath(localPath string, logLevel zapcore.Level) (err error)

SetupLoggerWithPath setups the logger by local file path.

func Warnf

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

Warnf logs messages at WARN level.

Types

type Logger

type Logger interface {
	// Debugf logs messages at DEBUG level.
	Debugf(format string, args ...interface{})
	// Infof logs messages at INFO level.
	Infof(format string, args ...interface{})
	// Warnf logs messages at WARN level.
	Warnf(format string, args ...interface{})
	// Errorf logs messages at ERROR level.
	Errorf(format string, args ...interface{})
	// Fatalf logs messages at FATAL level.
	Fatalf(format string, args ...interface{})
}

Logger is used for logging formatted messages.

var (
	// DefaultLogger is the default logger inside the tbuspp client.
	DefaultLogger Logger
)

Jump to

Keyboard shortcuts

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