Skip to content

Add logger injection to config.Manager #125

@pedronauck

Description

@pedronauck

Description

The config.Manager currently has TODO comments indicating the need for proper logger injection. Currently, errors are handled silently to avoid using fmt.Printf in production code.

Locations requiring logger injection:

  1. Manager.Close() - pkg/config/manager.go:120-123

    • Error handling when closing sources
  2. startWatching() - pkg/config/manager.go:152-155

    • Error handling during configuration reload
  3. startWatching() - pkg/config/manager.go:160-163

    • Error handling when setting up file watching

Proposed Solution

Add a logger interface to the Manager struct and allow it to be configured through the constructor or a setter method. This would enable proper error logging without using fmt.Printf.

Example Implementation

type Logger interface {
    Error(msg string, err error)
    Debug(msg string)
}

type Manager struct {
    // ... existing fields
    logger Logger
}

func (m *Manager) SetLogger(logger Logger) {
    m.logger = logger
}

Priority

Low - The current implementation safely handles errors without crashing, but proper logging would improve debugging and monitoring capabilities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions