log

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRemovedFields = []string{"component", "team", "service", "run_id"}
)
View Source
var I = Base()

I Global logger instance for use through the app

Functions

func AddGlobalTags

func AddGlobalTags(tags map[string]string)

AddGlobalTags adds global tags to all application loggers.

func GetLogrusFormatter added in v1.3.1

func GetLogrusFormatter() logrus.Formatter

func NewFilteredTextFormatter added in v1.3.2

func NewFilteredTextFormatter(removedFields []string) logrus.Formatter

func SetDD

func SetDD(enabled bool)

SetDD enables/disabled Datadog integration in the logger.

Types

type FilteredTextFormatter added in v1.3.2

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

FilteredTextFormatter is a logrus.TextFormatter that filters out some specific fields that are not needed for humans. These fields are usually more helpful for machines, and with json formatting for example.

func (*FilteredTextFormatter) Format added in v1.3.2

func (f *FilteredTextFormatter) Format(entry *logrus.Entry) ([]byte, error)

type KubehoundLogger

type KubehoundLogger struct {
	*logrus.Entry
}

Require our logger to append job or API related fields for easier filtering and parsing of logs within custom dashboards. Sticking to the "structured" log types also enables out of the box correlation of APM traces and log messages without the need for a custom index pipeline. See: https://docs.datadoghq.com/logs/log_collection/go/#configure-your-logger

func Base

func Base() *KubehoundLogger

Base returns the base logger for the application.

func Trace

func Trace(ctx context.Context, opts ...LoggerOption) *KubehoundLogger

Trace creates a logger from the current context, attaching trace and span IDs for use with APM.

type LoggerConfig

type LoggerConfig struct {
	Tags logrus.Fields // Tags applied to all logs.
	Mu   *sync.Mutex   // Lock to enable safe runtime changes.
	DD   bool          // Whether Datadog integration is enabled.
}

type LoggerOption

type LoggerOption func(*logrus.Entry) *logrus.Entry

func WithCollectedCluster added in v1.3.1

func WithCollectedCluster(name string) LoggerOption

WithCollectedCluster adds a component name tag to the logger.

func WithComponent

func WithComponent(name string) LoggerOption

WithComponent adds a component name tag to the logger.

Jump to

Keyboard shortcuts

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