Categorygithub.com/multiversx/mx-chain-logger-go
modulepackage
1.0.15
Repository: https://github.com/multiversx/mx-chain-logger-go.git
Documentation: pkg.go.dev

# README

mx-chain-logger-go

Multiversx' logger subsystem written in go

CLI options

Logs producer (Multiversx Node)

  • log-level: comma-separated pairs of (loggerName, logLevel)
  • log-correlation: option to include correlation elements in the logs
  • log-logger-name: option to include logger name in the logs

Example:

--log-level="*:INFO,processor:DEBUG" --log-correlation --log-logger-name

Logs viewer

  • level: comma-separated pairs of (loggerName, logLevel)
  • correlation: option to include correlation elements in the logs
  • logger-name: option to include logger name in the logs

Example:

--level="*:INFO,processor:DEBUG" --correlation --logger-name

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddLogObserver adds a new observer (writer + formatter) to the already built-in log observers queue This method is useful when adding a new output device for logs is needed (such as files, streams, API routes and so on).
ClearLogObservers clears the observers lists.
DisplayByteSlice converts the provided byte slice to its string representation using displayByteSlice function pointer.
GetCorrelation gets global correlation elements.
GetCurrentProfile gets the current logger profile.
GetLoggerLogLevel gets the log level of the specified logger.
GetLogLevel gets the corresponding log level from provided string.
GetLogLevelPattern returns the last set log level pattern.
GetLogOutputSubject returns the default log output subject.
GetOrCreate returns a log based on the name provided, generating a new log if there is no log with provided name.
IsEnabledCorrelation returns whether correlation elements are enabled.
IsEnabledLoggerName returns whether logger name is enabled.
NewLogger create a new logger instance.
NewLogLineWrapperFormatter creates a new logLineWrapperFormatter that is able to marshalize the provided logLine.
NewLogOutputSubject returns an initialized, empty logOutputSubject with no observers.
NewProfileChangeSubject -.
NotifyProfileChange notifies observers about a profile change.
ParseLogLevelAndMatchingString can parse a string in the form "MATCHING_STRING1:LOG_LEVEL1,MATCHING_STRING2:LOG_LEVEL2" into its corresponding log level and matching string.
RemoveLogObserver removes an exiting observer by providing the writer pointer.
SetCorrelationEpoch sets the current epoch as a log correlation element.
SetCorrelationRound sets the current round as a log correlation element.
SetCorrelationShard sets the current shard ID as a log correlation element.
SetCorrelationSubround sets the current sub-round as a log correlation element.
SetDisplayByteSlice sets the converter function from byte slice to string default, this will call hex.EncodeToString.
SetLogLevel changes the log level of the contained loggers.
SubscribeToProfileChange subscribes an observer.
ToggleCorrelation enables or disables correlation elements for log lines.
ToggleLoggerName enables / disables logger name.
ToHex converts the provided byte slice to its hex representation.
ToHexShort generates a short-hand of provided bytes slice showing only the first 3 and the last 3 bytes as hex in total, the resulting string is maximum 13 characters long.
UnmarshalProfile deserializes into a Profile object.
UnsubscribeFromProfileChange unsubscribes an observer.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
These constants are the string representation of the package logging levels.
These constants are the string representation of the package logging levels.
These constants are the string representation of the package logging levels.
These constants are the string representation of the package logging levels.
These constants are the string representation of the package logging levels.
These constants are the string representation of the package logging levels.

# Variables

ErrInvalidLogLevelPattern signals that an un-parsable log level and patter was provided.
ErrNilDisplayByteSliceHandler signals that a nil display byte slice handler has been provided.
ErrNilFormatter signals that a nil formatter has been provided.
ErrNilMarshalizer signals that a nil marshalizer has been provided.
ErrNilWriter signals that a nil writer has been provided.
ErrWriterNotFound signals that the provided writer was not found while searching container list.
Levels contain all defined levels as a slice for an easier iteration.

# Structs

ConsoleFormatter implements formatter interface and is used to format log lines to be written on the console It uses ANSI-color for colorized console/terminal output.
LogLine is the structure used to hold a log line.
LogLineWrapper is a wrapper over protobuf.LogLineMessage that enables the structure to be used with protobuf marshaller.
PlainFormatter implements formatter interface and is used to format log lines to be written in the same form as ConsoleFormatter but it doesn't use the ANSI colors (useful when writing to a file, for example).
Profile holds global logger options.

# Interfaces

Formatter describes what a log formatter should be able to do.
Logger defines the behavior of a data logger component.
LogLineHandler defines the get methods for a log line struct used by the formatter interface.
LogOutputHandler defines the properties of a subject-observer component able to output log lines.
Marshalizer defines the 2 basic operations: serialize (marshal) and deserialize (unmarshal).
ProfileChangeObserver defines the interface for observing profile changes.

# Type aliases

LogLevel defines the priority level of a log line.