logging

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 8 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Account

func Account(a fmt.Stringer) zap.Field

Account constructs a field with the given VEGA account proto value.

func AssetID

func AssetID(id string) zap.Field

func BigInt

func BigInt(key string, val fmt.Stringer) zap.Field

BigInt constructs a field with the given key and value.

func BigUint

func BigUint(key string, val fmt.Stringer) zap.Field

BigUint constructs a field with the given key and value.

func Binary

func Binary(key string, val []byte) zap.Field

Binary constructs a field that carries an opaque binary blob.

Binary data is serialized in an encoding-appropriate format. For example, zap's JSON encoder base64-encodes binary blobs. To log UTF-8 encoded text, use ByteString.

func Bool

func Bool(key string, val bool) zap.Field

Bool constructs a field that carries a bool.

func ByteString

func ByteString(key string, val []byte) zap.Field

ByteString constructs a field that carries UTF-8 encoded text as a []byte. To log opaque binary blobs (which aren't necessarily valid UTF-8), use Binary.

func Candle

func Candle(c fmt.Stringer) zap.Field

Candle constructs a field with the given VEGA candle proto value.

func CandleWithTag

func CandleWithTag(c fmt.Stringer, tag string) zap.Field

CandleWithTag constructs a field with the given VEGA candle proto value and key equal to the tag string.

func Complex128

func Complex128(key string, val complex128) zap.Field

Complex128 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex128 to interface{}).

func Complex64

func Complex64(key string, val complex64) zap.Field

Complex64 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex64 to interface{}).

func Decimal

func Decimal(key string, val fmt.Stringer) zap.Field

Decimal constructs a field with the given key and value.

func Duration

func Duration(key string, value time.Duration) zap.Field

func Error

func Error(val error) zap.Field

Error constructs a field with the given error value.

func Float32

func Float32(key string, val float32) zap.Field

Float32 constructs a field that carries a float32. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.

func Float64

func Float64(key string, val float64) zap.Field

Float64 constructs a field that carries a float64. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.

func Hash

func Hash(h []byte) zap.Field

func Int

func Int(key string, val int) zap.Field

Int constructs a field with the given key and value.

func Int16

func Int16(key string, val int16) zap.Field

Int16 constructs a field with the given key and value.

func Int32

func Int32(key string, val int32) zap.Field

Int32 constructs a field with the given key and value.

func Int64

func Int64(key string, val int64) zap.Field

Int64 constructs a field with the given key and value.

func Int8

func Int8(key string, val int8) zap.Field

Int8 constructs a field with the given key and value.

func LiquidityID

func LiquidityID(id string) zap.Field

func LiquidityProvisionAmendment

func LiquidityProvisionAmendment(
	lp fmt.Stringer,
) zap.Field

func LiquidityProvisionAmendmentProto

func LiquidityProvisionAmendmentProto(
	lp *commandspb.LiquidityProvisionAmendment,
) zap.Field

func LiquidityProvisionCancellation

func LiquidityProvisionCancellation(
	lp fmt.Stringer,
) zap.Field

func LiquidityProvisionCancellationProto

func LiquidityProvisionCancellationProto(
	lp *commandspb.LiquidityProvisionCancellation,
) zap.Field

func LiquidityProvisionSubmission

func LiquidityProvisionSubmission(
	lp fmt.Stringer,
) zap.Field

func LiquidityProvisionSubmissionProto

func LiquidityProvisionSubmissionProto(
	lp *commandspb.LiquidityProvisionSubmission,
) zap.Field

func Market

func Market(m fmt.Stringer) zap.Field

Market constructs a field with the given VEGA market proto value.

func MarketID

func MarketID(id string) zap.Field

func Order

func Order(o fmt.Stringer) zap.Field

Order constructs a field with the given VEGA order value.

func OrderAmendment

func OrderAmendment(oa fmt.Stringer) zap.Field

OrderAmendment constructs a single string field to contain all the object information.

func OrderAmendmentProto

func OrderAmendmentProto(oa *commandspb.OrderAmendment) zap.Field

OrderAmendmentProto constructs a single string field to contain all the object information.

func OrderCancellation

func OrderCancellation(oc fmt.Stringer) zap.Field

func OrderID

func OrderID(id string) zap.Field

func OrderSubmission

func OrderSubmission(os fmt.Stringer) zap.Field

OrderSubmission constructs a single string field to contain all the object information.

func OrderSubmissionProto

func OrderSubmissionProto(os *commandspb.OrderSubmission) zap.Field

OrderSubmissionProto constructs a single string field to contain all the object information.

func OrderWithTag

func OrderWithTag(o fmt.Stringer, tag string) zap.Field

OrderWithTag constructs a field with the given VEGA order proto value and key equal to the tag string.

func Party

func Party(p fmt.Stringer) zap.Field

Party constructs a field with the given VEGA party proto value.

func PartyID

func PartyID(id string) zap.Field

func ProposalID

func ProposalID(id string) zap.Field

func ProtoAccount

func ProtoAccount(a ptypes.Account) zap.Field

ProtoAccount constructs a field with the given VEGA account proto value.

func ProtoOrder

func ProtoOrder(o ptypes.Order) zap.Field

ProtoOrder constructs a field with the given VEGA order proto value.

func Reflect

func Reflect(key string, val interface{}) zap.Field

Reflect constructs a field by running reflection over all the field of value passed as a parameter. This should never be used we basic log level, only in the case of Debug log level, and with guards on top of the actual log call for this level.

func String

func String(key string, val string) zap.Field

String constructs a field with the given key and value.

func Strings

func Strings(key string, val []string) zap.Field

Strings constructs a field with the given key and value.

func Time

func Time(key string, t time.Time) zap.Field

Time display a time.

func TraceID

func TraceID(e Tracer) zap.Field

TraceID logs the event traceID.

func Trade

func Trade(t fmt.Stringer) zap.Field

Trade constructs a field with the given VEGA trade proto value.

func Uint

func Uint(key string, val uint) zap.Field

Uint constructs a field with the given key and value.

func Uint16

func Uint16(key string, val uint16) zap.Field

Uint16 constructs a field with the given key and value.

func Uint32

func Uint32(key string, val uint32) zap.Field

Uint32 constructs a field with the given key and value.

func Uint64

func Uint64(key string, val uint64) zap.Field

Uint64 constructs a field with the given key and value.

func Uint8

func Uint8(key string, val uint8) zap.Field

Uint8 constructs a field with the given key and value.

func Uintptr

func Uintptr(key string, val uintptr) zap.Field

Uintptr constructs a field with the given key and value.

func WithdrawSubmission

func WithdrawSubmission(
	lp fmt.Stringer,
) zap.Field

func WithdrawSubmissionProto

func WithdrawSubmissionProto(
	lp *commandspb.WithdrawSubmission,
) zap.Field

func WithdrawalID

func WithdrawalID(id string) zap.Field

Types

type Config

type Config struct {
	Environment string  `long:"env" choice:"dev" choice:"custom"`
	Custom      *Custom `tomlcp:"This section takes effect only when Environment is set to \"custom\"."`
}

Config contains the configurable items for this package.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package-specific configuration, given a pointer to a logger instance to be used for logging within the package.

type Custom

type Custom struct {
	Zap        *Zap
	ZapEncoder *ZapEncoder
}

Custom contains the custom log config.

type Level

type Level int8

A Level is a logging priority. Higher levels are more important.

const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = -1
	// InfoLevel is the default logging priority.
	InfoLevel Level = 0
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel Level = 1
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel Level = 2
	// PanicLevel logs a message, then panics.
	PanicLevel Level = 4
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel Level = 5
)

Logging levels (matching zap core internals).

func ParseLevel

func ParseLevel(l string) (Level, error)

ParseLevel parse a log level from a string.

func (Level) String

func (l Level) String() string

String marshal a log level to a string representation.

func (*Level) ZapLevel

func (l *Level) ZapLevel() zapcore.Level

ZapLevel return the log level of internal zap level.

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

Logger is an abstraction on to of the zap logger.

func New

func New(zaplogger *zap.Logger, zapconfig *zap.Config, environment, name string) *Logger

New instantiate a new logger.

func NewDevLogger

func NewDevLogger() *Logger

NewDevLogger creates a new logger suitable for development environments.

func NewLoggerFromConfig

func NewLoggerFromConfig(config Config) *Logger

NewLoggerFromConfig creates a standard or custom logger.

func NewProdLogger

func NewProdLogger() *Logger

NewProdLogger creates a new logger suitable for production environments, including sending logs to ElasticSearch.

func NewTestLogger

func NewTestLogger() *Logger

NewTestLogger creates a new logger suitable for golang unit test environments, ie when running "go test ./...".

func (*Logger) AtExit

func (log *Logger) AtExit()

AtExit flushes the logs before exiting the process. Useful when an app shuts down so we store all logging possible. This is meant to be used with defer when initializing your logger.

func (*Logger) Check

func (log *Logger) Check(l Level) bool

Check helps avoid spending CPU time on log entries that will never be printed.

func (*Logger) Clone

func (log *Logger) Clone() *Logger

Clone will clone the internal logger.

func (*Logger) Debugf

func (log *Logger) Debugf(s string, args ...interface{})

Debugf implement badger interface.

func (*Logger) Errorf

func (log *Logger) Errorf(s string, args ...interface{})

Errorf implement badger interface.

func (*Logger) GetEnvironment

func (log *Logger) GetEnvironment() string

GetEnvironment returns the current environment name.

func (*Logger) GetLevel

func (log *Logger) GetLevel() Level

GetLevel returns the log level.

func (*Logger) GetLevelString

func (log *Logger) GetLevelString() string

GetLevelString return a string representation of the current log level.

func (*Logger) GetName

func (log *Logger) GetName() string

GetName return the name of this logger.

func (*Logger) GooseLogger

func (log *Logger) GooseLogger() *ZapGooseLogger

func (*Logger) Infof

func (log *Logger) Infof(s string, args ...interface{})

Infof implement badger interface.

func (*Logger) IsDebug

func (log *Logger) IsDebug() bool

IsDebug returns true if logger level is less or equal to DebugLevel.

func (*Logger) Named

func (log *Logger) Named(name string) *Logger

Named instantiate a new logger by cloning it first and name it with the string specified.

func (*Logger) SetLevel

func (log *Logger) SetLevel(level Level)

SetLevel change the level of this logger.

func (*Logger) ToSugared

func (log *Logger) ToSugared() *zap.SugaredLogger

func (*Logger) Warningf

func (log *Logger) Warningf(s string, args ...interface{})

Warningf implement badger interface.

func (*Logger) With

func (log *Logger) With(fields ...zap.Field) *Logger

With will add default field to each logs.

type Tracer

type Tracer interface {
	TraceID() string
}

type Zap

type Zap struct {
	Level            Level
	Development      bool
	Encoding         string // console or json
	OutputPaths      []string
	ErrorOutputPaths []string
}

Zap configures a ZapConfig.

type ZapEncoder

type ZapEncoder struct {
	CallerKey      string
	EncodeCaller   string
	EncodeDuration string
	EncodeLevel    string
	EncodeName     string
	EncodeTime     string
	LevelKey       string
	LineEnding     string
	MessageKey     string
	NameKey        string
	TimeKey        string
}

ZapEncoder configures a ZapEncoderConfig.

type ZapGooseLogger added in v0.55.0

type ZapGooseLogger struct {
	zap.SugaredLogger
}

func (*ZapGooseLogger) Print added in v0.55.0

func (l *ZapGooseLogger) Print(v ...interface{})

func (*ZapGooseLogger) Printf added in v0.55.0

func (l *ZapGooseLogger) Printf(format string, v ...interface{})

func (*ZapGooseLogger) Println added in v0.55.0

func (l *ZapGooseLogger) Println(v ...interface{})

Jump to

Keyboard shortcuts

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