log

package
v5.8.1-8 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package log defines the logging interface used internally by the driver and provides default logging implementations.

Index

Constants

View Source
const (
	Bolt3   = "bolt3"
	Bolt4   = "bolt4"
	Bolt5   = "bolt5"
	Driver  = "driver"
	Pool    = "pool"
	Router  = "router"
	Session = "session"
)

List of component names used as parameter to logger functions.

Variables

This section is empty.

Functions

func NewId

func NewId() string

NewId generates a new id atomically.

Types

type BoltLogger

type BoltLogger interface {
	LogClientMessage(context string, msg string, args ...any)
	LogServerMessage(context string, msg string, args ...any)
}

type Console

type Console struct {
	Errors bool
	Infos  bool
	Warns  bool
	Debugs bool
}

Console is a simple logger that logs to stdout/console. Turn the different log levels on/off as wished, all are off by default.

func (*Console) Debugf

func (l *Console) Debugf(name, id string, msg string, args ...any)

func (*Console) Error

func (l *Console) Error(name, id string, err error)

func (*Console) Infof

func (l *Console) Infof(name, id string, msg string, args ...any)

func (*Console) Warnf

func (l *Console) Warnf(name, id string, msg string, args ...any)

type ConsoleBoltLogger

type ConsoleBoltLogger struct {
}

func (*ConsoleBoltLogger) LogClientMessage

func (cbl *ConsoleBoltLogger) LogClientMessage(id, msg string, args ...any)

func (*ConsoleBoltLogger) LogServerMessage

func (cbl *ConsoleBoltLogger) LogServerMessage(id, msg string, args ...any)

type Logger

type Logger interface {
	// Error is called whenever the driver encounters an error that might
	// or might not cause a retry operation which means that all logged
	// errors are not critical. Type of err might or might not be a publicly
	// exported type. The same root cause of an error might be reported
	// more than once by different components using same or different err types.
	Error(name string, id string, err error)
	Warnf(name string, id string, msg string, args ...any)
	Infof(name string, id string, msg string, args ...any)
	Debugf(name string, id string, msg string, args ...any)
}

Logger is used throughout the driver for logging purposes. Driver client can implement this interface and provide an implementation upon driver creation.

All logging functions takes a name and id that corresponds to the name of the logging component and it's identity, for example "router" and "1" to indicate who is logging and what instance.

Database connections takes to form of "bolt3" and "bolt-123@192.168.0.1:7687" where "bolt3" is the name of the protocol handler in use, "bolt-123" is the databases identity of the connection on server "192.168.0.1:7687".

type Void

type Void struct{}

Logger implementation that throws away all log events.

func (Void) Debugf

func (l Void) Debugf(name, id string, msg string, args ...any)

func (Void) Error

func (l Void) Error(name, id string, err error)

func (Void) Infof

func (l Void) Infof(name, id string, msg string, args ...any)

func (Void) Warnf

func (l Void) Warnf(name, id string, msg string, args ...any)

Jump to

Keyboard shortcuts

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