logging

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MPL-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ACL                string = "acl"
	Agent              string = "agent"
	AntiEntropy        string = "anti_entropy"
	AutoEncrypt        string = "auto_encrypt"
	AutoConfig         string = "auto_config"
	Autopilot          string = "autopilot"
	AWS                string = "aws"
	Azure              string = "azure"
	CA                 string = "ca"
	Catalog            string = "catalog"
	CentralConfig      string = "central_config"
	ConfigEntry        string = "config_entry"
	Connect            string = "connect"
	Consul             string = "consul"
	ConsulClient       string = "client"
	ConsulServer       string = "server"
	Coordinate         string = "coordinate"
	DNS                string = "dns"
	Envoy              string = "envoy"
	FederationState    string = "federation_state"
	FSM                string = "fsm"
	GatewayLocator     string = "gateway_locator"
	HTTP               string = "http"
	Intentions         string = "intentions"
	Internal           string = "internal"
	KV                 string = "kvs"
	LAN                string = "lan"
	Leader             string = "leader"
	Legacy             string = "legacy"
	License            string = "license"
	Manager            string = "manager"
	Memberlist         string = "memberlist"
	MeshGateway        string = "mesh_gateway"
	Namespace          string = "namespace"
	NetworkAreas       string = "network_areas"
	Operator           string = "operator"
	PreparedQuery      string = "prepared_query"
	Proxy              string = "proxy"
	ProxyConfig        string = "proxycfg"
	Raft               string = "raft"
	Replication        string = "replication"
	Router             string = "router"
	RPC                string = "rpc"
	Serf               string = "serf"
	Session            string = "session"
	Sentinel           string = "sentinel"
	Snapshot           string = "snapshot"
	TerminatingGateway string = "terminating_gateway"
	TLSUtil            string = "tlsutil"
	Transaction        string = "txn"
	WAN                string = "wan"
	Watch              string = "watch"
	XDS                string = "xds"
	Vault              string = "vault"
)

Variables

This section is empty.

Functions

func AllowedLogLevels

func AllowedLogLevels() []string

func LevelFromString

func LevelFromString(level string) hclog.Level

Backwards compatibility with former ERR log level

func Setup

func Setup(config Config, out io.Writer) (hclog.InterceptLogger, error)

Setup logging from Config, and return an hclog Logger.

Logs may be written to out, and optionally to syslog, and a file.

func ValidateLogLevel

func ValidateLogLevel(minLevel string) bool

ValidateLogLevel verifies that a new log level is valid

Types

type Config

type Config struct {
	// LogLevel is the minimum level to be logged.
	LogLevel string

	// LogJSON controls outputing logs in a JSON format.
	LogJSON bool

	// Name is the name the returned logger will use to prefix log lines.
	Name string

	// EnableSyslog controls forwarding to syslog.
	EnableSyslog bool

	// SyslogFacility is the destination for syslog forwarding.
	SyslogFacility string

	//LogFilePath is the path to write the logs to the user specified file.
	LogFilePath string

	//LogRotateDuration is the user specified time to rotate logs
	LogRotateDuration time.Duration

	//LogRotateBytes is the user specified byte limit to rotate logs
	LogRotateBytes int

	//LogRotateMaxFiles is the maximum number of past archived log files to keep
	LogRotateMaxFiles int
}

Config is used to set up logging.

type GRPCLogger

type GRPCLogger struct {
	// contains filtered or unexported fields
}

GRPCLogger wrapps a hclog.Logger and implements the grpclog.LoggerV2 interface allowing gRPC servers to log to the standard Consul logger.

func NewGRPCLogger

func NewGRPCLogger(logLevel string, logger hclog.Logger) *GRPCLogger

NewGRPCLogger creates a grpclog.LoggerV2 that will output to the supplied logger with Severity/Verbosity level appropriate for the given config.

Note that grpclog has Info, Warning, Error, Fatal severity levels AND integer verbosity levels for additional info. Verbose logs in hclog are always DEBUG severity so we map Info,V0 to INFO, Info,V1 to DEBUG, and Info,V>1 to TRACE.

func (*GRPCLogger) Error

func (g *GRPCLogger) Error(args ...interface{})

Error implements grpclog.LoggerV2

func (*GRPCLogger) Errorf

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

Errorf implements grpclog.LoggerV2

func (*GRPCLogger) Errorln

func (g *GRPCLogger) Errorln(args ...interface{})

Errorln implements grpclog.LoggerV2

func (*GRPCLogger) Fatal

func (g *GRPCLogger) Fatal(args ...interface{})

Fatal implements grpclog.LoggerV2

func (*GRPCLogger) Fatalf

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

Fatalf implements grpclog.LoggerV2

func (*GRPCLogger) Fatalln

func (g *GRPCLogger) Fatalln(args ...interface{})

Fatalln implements grpclog.LoggerV2

func (*GRPCLogger) Info

func (g *GRPCLogger) Info(args ...interface{})

Info implements grpclog.LoggerV2

func (*GRPCLogger) Infof

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

Infof implements grpclog.LoggerV2

func (*GRPCLogger) Infoln

func (g *GRPCLogger) Infoln(args ...interface{})

Infoln implements grpclog.LoggerV2

func (*GRPCLogger) V

func (g *GRPCLogger) V(l int) bool

V implements grpclog.LoggerV2

func (*GRPCLogger) Warning

func (g *GRPCLogger) Warning(args ...interface{})

Warning implements grpclog.LoggerV2

func (*GRPCLogger) Warningf

func (g *GRPCLogger) Warningf(format string, args ...interface{})

Warningf implements grpclog.LoggerV2

func (*GRPCLogger) Warningln

func (g *GRPCLogger) Warningln(args ...interface{})

Warningln implements grpclog.LoggerV2

type GatedWriter

type GatedWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

GatedWriter is an io.Writer implementation that buffers all of its data into an internal buffer until it is told to let data through.

func (*GatedWriter) Flush

func (w *GatedWriter) Flush()

Flush tells the GatedWriter to flush any buffered data and to stop buffering.

func (*GatedWriter) Write

func (w *GatedWriter) Write(p []byte) (n int, err error)

type LogFile

type LogFile struct {

	//LastCreated represents the creation time of the latest log
	LastCreated time.Time

	//FileInfo is the pointer to the current file being written to
	FileInfo *os.File

	//MaxBytes is the maximum number of desired bytes for a log file
	MaxBytes int

	//BytesWritten is the number of bytes written in the current log file
	BytesWritten int64

	// Max rotated files to keep before removing them.
	MaxFiles int
	// contains filtered or unexported fields
}

LogFile is used to setup a file based logger that also performs log rotation

func (*LogFile) Write

func (l *LogFile) Write(b []byte) (n int, err error)

Write is used to implement io.Writer

type LogSetupErrorFn added in v1.8.1

type LogSetupErrorFn func(string)

type SyslogWrapper

type SyslogWrapper struct {
	// contains filtered or unexported fields
}

SyslogWrapper is used to cleanup log messages before writing them to a Syslogger. Implements the io.Writer interface.

func (*SyslogWrapper) Write

func (s *SyslogWrapper) Write(p []byte) (int, error)

Write is used to implement io.Writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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