logging

package
v0.0.0-...-f94b3ec Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: AGPL-3.0 Imports: 3 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).

The environment variable `GNET_LOGGING_MODE` determines which zap logger type will be created for logging, "prod" (case-insensitive) means production logger while other values except "prod" including "dev" (case-insensitive) represent development logger.

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.

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 gnet server.
	DefaultLogger Logger
)

Jump to

Keyboard shortcuts

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