logger

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewLogger(logger logger.Logger) *Logger

NewLogger creates a new Logger middleware instance. The provided logger is used to output task lifecycle messages.

func (*Logger) Middleware

func (m *Logger) Middleware(task *runner.Task, next runner.Process) runner.Process

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.

Jump to

Keyboard shortcuts

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