Skip to content

Improvement for logging in maxprocs #95

@gorodet-sky

Description

@gorodet-sky

Hey!

I’d like to propose adding support for structured logging to the maxprocs package. Currently, logging is implemented using a printf function that accepts a formatted string. While this is convenient, it’s not always sufficient for modern systems where structured logging is required (e.g., JSON format for metrics collection or integration with monitoring systems).

What I’m proposing:

  1. Add support for structured logging via an interface similar to slog, logrus or zap. For example:
type Logger interface {
    Info(msg string, fields map[string]interface{})
    Error(msg string, fields map[string]interface{})
}
  1. Maintain backward compatibility by keeping the ability to use the existing printf method. This can be achieved by introducing a new option, StructuredLogger:
func StructuredLogger(logger Logger) Option {
    return optionFunc(func(cfg *config) {
        cfg.structuredLogger = logger
    })
}
  1. If no structured logger is set, continue using printf as it currently works.

Why this matters:

  • Structured logs are easier to analyze and integrate with monitoring systems.
  • This would make the package more flexible and modern without breaking existing functionality.

I'm ready to make a PR with these changes. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions