Documentation
¶
Overview ¶
Common log configuration, initialization and flushing functions for osbuild projects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidURL = errors.New("invalid URL")
var ErrSentryInitialization = errors.New("sentry initialization error")
Functions ¶
func Flush ¶
func Flush()
Flush flushes all pending logs to the configured outputs. Blocks until all logs are written.
func InitializeLogging ¶
func InitializeLogging(ctx context.Context, config LoggingConfig) error
InitializeLogging initializes the logging system with the provided configuration. Use Flush to ensure all logs are written before exiting. Subsequent calls to InitializeLogging will have no effect and will not return any error.
Types ¶
type CloudWatchConfig ¶
type CloudWatchConfig struct { // Enabled is a flag to enable this output. Enabled bool // Logging level for this output. Strings "debug", "info", "warn", "error", "fatal", "panic" are accepted. // Keep in mind that log/slog has only 4 levels: Debug, Info, Warn, Error. Default value is "debug". Level string // AWSRegion is the AWS region. AWSRegion string // AWSKey is the AWS access key. AWSKey string // AWSSecret is the AWS secret key. AWSSecret string // AWSSession is an optional AWS session token. AWSSession string // AWSLogGroup is the AWS CloudWatch log group. AWSLogGroup string // AWSLogStream is the AWS CloudWatch log stream. AWSLogStream string }
CloudWatchConfig is the configuration for the CloudWatch output.
type JournalConfig ¶
type JournalConfig struct { // Enabled is a flag to enable this output. Enabled bool // Logging level for this output. Strings "debug", "info", "warn", "error", "fatal", "panic" are accepted. // Keep in mind that log/slog has only 4 levels: Debug, Info, Warn, Error. Default value is "debug". Level string }
JournalConfig is the configuration for the system journal.
type LoggingConfig ¶
type LoggingConfig struct { StdoutConfig StdoutConfig JournalConfig JournalConfig SplunkConfig SplunkConfig CloudWatchConfig CloudWatchConfig SentryConfig SentryConfig TracingConfig TracingConfig }
LoggingConfig is the configuration for the logging system.
type SentryConfig ¶
type SentryConfig struct { // Enabled is a flag to enable Sentry. Enabled bool // DSN is the Sentry DSN. DSN string }
SentryConfig is the configuration for the Sentry output. Only log entries with error level are sent to Sentry.
type SplunkConfig ¶
type SplunkConfig struct { // Enabled is a flag to enable this output. Enabled bool // Logging level for this output. Strings "debug", "info", "warn", "error", "fatal", "panic" are accepted. // Keep in mind that log/slog has only 4 levels: Debug, Info, Warn, Error. Default value is "debug". Level string // URL is the Splunk HEC URL. URL string // Token is the Splunk HEC token. Token string // Source is the Splunk HEC source. Source string // Hostname is the Splunk HEC hostname. Hostname string }
SplunkConfig is the configuration for the Splunk output.
type StdoutConfig ¶
type StdoutConfig struct { // Enabled is a flag to enable this output. Enabled bool // Logging level for this output. Strings "debug", "info", "warn", "error", "fatal", "panic" are accepted. // Keep in mind that log/slog has only 4 levels: Debug, Info, Warn, Error. Default value is "debug". Level string // Format is the log format to use for stdout logging. Possible values are "json" and "text". Format string }
StdoutConfig is the configuration for the standard output.
type TracingConfig ¶
type TracingConfig struct { // Enabled is a flag to enable tracing Enabled bool // CustomAttrs is a list of custom static attributes to add to every log entry. To add // dynamic attributes, use ContextCallback that can access context. CustomAttrs []slog.Attr // ContextCallback is an optional callback function that is called for each log entry // to add additional attributes to the log entry. ContextCallback strc.MultiCallback }
TracingConfig is the configuration for strc.