logging

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ACL           string = "acl"
	Agent         string = "agent"
	AntiEntropy   string = "anti_entropy"
	AutoEncrypt   string = "auto_encrypt"
	Autopilot     string = "autopilot"
	AWS           string = "aws"
	Azure         string = "azure"
	CA            string = "ca"
	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"
	FSM           string = "fsm"
	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"
	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"
	TLSUtil       string = "tlsutil"
	Transaction   string = "txn"
	WAN           string = "wan"
	Watch         string = "watch"
)

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 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(config *Config, 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 glog are always INFO 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 Setup

func Setup(config *Config, ui cli.Ui) (hclog.InterceptLogger, *GatedWriter, io.Writer, bool)

Setup is used to perform setup of several logging objects:

  • A hclog.Logger is used to perform filtering by log level and write to io.Writer.
  • A GatedWriter is used to buffer logs until startup UI operations are complete. After this is flushed then logs flow directly to output destinations.
  • An io.Writer is provided as the sink for all logs to flow to.

The provided ui object will get any log messages related to setting up logging itself, and will also be hooked up to the gated logger. The final bool parameter indicates if logging was set up successfully.

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 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