Documentation
ΒΆ
Index ΒΆ
- func Debug(ctx context.Context, message string, additionalData ...map[string]any)
- func Entry(ctx context.Context, entry any)
- func Error(ctx context.Context, err error, additionalData ...map[string]any)
- func Info(ctx context.Context, message string, additionalData ...map[string]any)
- func Setup(cfg Config)
- func Trace(ctx context.Context, message string, additionalData ...map[string]any)
- func Warn(ctx context.Context, message string, additionalData ...map[string]any)
- type Config
- type Format
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func Debug ΒΆ
Debug logs a message for detailed debugging information.
This function is intended for developers to log detailed information that is more verbose than info logs, useful for diagnosing issues during development or troubleshooting.
Parameters:
- ctx (context.Context): The context associated with the log entry, used for metadata like trace IDs.
- message (string): The log message to be recorded.
- additionalData (...map[string]any): Variadic slice of maps containing additional key-value data to include in the structured log entry. These maps are merged internally.
Returns:
- None. This function produces side effects by emitting a log entry through the logger pipeline.
func Entry ΒΆ
Entry logs a fully preconstructed log entry.
This function is useful when you already have a custom or advanced entry object that conforms to your internal logging schema or log serialization format.
Parameters:
- ctx (context.Context): The execution context.
- entry (any): A prebuilt structured log entry object. May be a map, struct, or custom type, depending on your loggerβs capabilities.
Returns:
- None. The entry is passed directly to the logger for serialization and dispatch.
func Error ΒΆ
Error logs a structured error message, along with optional diagnostic data.
This function is intended for actual runtime errors, exceptions, or unexpected failures. It transforms the error into a structured log entry using `entries.NewErrorLogEntry`.
Parameters:
- ctx (context.Context): The context for propagating metadata like correlation IDs.
- err (error): The error instance to log. Expected to be non-nil.
- additionalData (...map[string]any): Optional structured metadata to assist in debugging.
Returns:
- None. The error is emitted as a structured log entry.
func Info ΒΆ
Info logs an informational message, optionally enriched with additional contextual data.
This function should be used to log general application events that are useful for understanding normal system behavior (e.g., startup, configuration loaded, user actions).
Parameters:
- ctx (context.Context): The context associated with the log entry. Used to extract metadata such as trace IDs or user/session information.
- message (string): The log message to be recorded.
- additionalData (...map[string]any): Variadic slice of maps containing additional key-value data to include in the structured log entry. These maps are merged internally.
Returns:
- None. This function produces side effects by emitting a log entry through the logger pipeline.
func Trace ΒΆ
Trace logs a detailed message for low-level debugging purposes.
This function is intended for developers to trace execution flow and inspect internal state during development or troubleshooting. It should not be used in production unless necessary due to its verbose nature.
Parameters:
- ctx (context.Context): The context associated with the log entry, used for metadata like trace IDs.
- message (string): The log message to be recorded.
- additionalData (...map[string]any): Variadic slice of maps containing additional key-value data to include in the structured log entry. These maps are merged internally.
Returns:
- None. This function produces side effects by emitting a log entry through the logger pipeline.
func Warn ΒΆ
Warn logs a warning message indicating a potential issue that is not necessarily an error.
Use this function to highlight situations that may need investigation but are not critical, such as configuration overrides, slow responses, or unexpected inputs.
Parameters:
- ctx (context.Context): The execution context for the log entry.
- message (string): A descriptive warning message.
- additionalData (...map[string]any): Optional structured data to attach to the log for debugging.
Returns:
- None. The log entry is processed and forwarded to the underlying logging system.