logging

package
v0.0.0-...-55ed90b Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Logger is the global logger for the logging package. Callers should use this Logger
	// to ensure that logging functionality is consistent across the Infracost codebase.
	//
	// It is advised to create child Loggers as needed and pass them into packages with
	// relevant log metadata. This can be done by using the With method:
	//
	//		childLogger := logging.Logger.With().Str("additional", "field")
	//		foo := MyStruct{Logger: childLogger}
	//		foo.DoSomething()
	//
	// Child loggers will inherit the parent metadata fields, unless the child logger sets metadata
	// field information with the same key. In this case child fields will overwrite the parent field.
	Logger = zerolog.New(os.Stderr).With().Timestamp().Logger()
)

Functions

func ConfigureBaseLogger

func ConfigureBaseLogger(c Config) error

ConfigureBaseLogger configures the global Logger using the provided Config.

Types

type Config

type Config interface {
	// LogWriter returns the writer the Logger should use to write logs to.
	// In most cases this should be stderr, but it can also be a file.
	LogWriter() io.Writer
	// WriteLevel is the log level that the Logger writes to LogWriter.
	WriteLevel() string
	// LogFields sets the meta fields that are added to any log line entries.
	LogFields() map[string]interface{}
}

Config is an interface that fetches Logger configuration details for the Logger. This is used so that the logging packages does not use any other Infracost packages, avoiding circular deps problems.

Jump to

Keyboard shortcuts

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