Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Component = &component.Component{ Name: "runner.logger", Dependencies: component.Components{ runner.Component, }, Init: component.StepFunc(func(container container.Container) error { return container.Provide(NewLogger) }), PreExecute: component.StepFunc(func(container container.Container) error { return container.Invoke(func(r runner.Runner, middleware *Logger) { r.Use(middleware) }) }), }
Component is a ready-to-use Compogo component that automatically adds task lifecycle logging middleware to the application's runner.
It depends on runner.Component and registers itself during the PreRun phase. Logs will show when tasks start, complete, or encounter errors.
Usage:
compogo.WithComponents(
runner.Component,
logger.Component, // ← adds lifecycle logging to all tasks
)
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a middleware that logs task lifecycle events: - When a task starts running - When a task finishes (with error details if any)
func NewLogger ¶
NewLogger creates a new Logger middleware instance. The provided logger is used to output task lifecycle messages.
func (*Logger) Middleware ¶
Middleware wraps a task's process function with lifecycle logging. It logs "running" before the task starts, and "shutdown" (with error) after the task completes. If the task returns an error, it is logged with a stack trace for debugging.