common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ValidLogFormats contains all supported logging formats
	ValidLogFormats = []LogFormat{LogFormatPlain, LogFormatJSON}
)

Functions

func Cleanup

func Cleanup()

Cleanup closes the log file if it was opened.

func CopyMap

func CopyMap(original map[string]interface{}) map[string]interface{}

CopyMap creates a shallow copy of a map[string]interface{}.

func DebugOutput

func DebugOutput(format string, args ...interface{})

func InterfaceToSlice

func InterfaceToSlice(value interface{}) ([]interface{}, bool)

InterfaceToSlice attempts to convert an interface{} to a []interface{}. It handles cases where the underlying type is already []interface{} or a slice of a specific type (e.g., []string, []int).

func IsValidLogFormat

func IsValidLogFormat(format string) bool

IsValidLogFormat checks if the given format is supported

func LogDebug

func LogDebug(msg string, fields map[string]interface{})

LogDebug logs a debug message with structured key-value fields.

func LogError

func LogError(msg string, fields map[string]interface{})

LogError logs an error message with structured key-value fields.

func LogInfo

func LogInfo(msg string, fields map[string]interface{})

LogInfo logs an info message with structured key-value fields.

func LogWarn

func LogWarn(msg string, fields map[string]interface{})

LogWarn logs a warning message with structured key-value fields.

func RemoveFromSlice

func RemoveFromSlice(s []string, item string) []string

func SetExecutionID

func SetExecutionID(id string)

SetExecutionID sets a execution ID field that will be included in all subsequent log entries This replaces the logger instance with a new one including the field.

func SetLogFile

func SetLogFile(path string) error

SetLogFile sets the output file for logging

func SetLogFormat

func SetLogFormat(loggingCfg config.LoggingConfig) error

SetLogFormat reconfigures the logger based on the logging configuration.

func SetLogLevel

func SetLogLevel(level string)

SetLogLevel sets the logging level

func SyncMapToMap

func SyncMapToMap(m *sync.Map) map[string]interface{}

SyncMapToMap converts a sync.Map to a regular map[string]interface{}. Note: This provides a snapshot. Concurrent modifications to the original sync.Map after this call won't be reflected in the returned map.

Types

type LogFormat

type LogFormat string

LogFormat represents a supported logging format

const (
	LogFormatPlain LogFormat = "plain"
	LogFormatJSON  LogFormat = "json"
)

Available log formats

Jump to

Keyboard shortcuts

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