You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The project requires a logging system with structured and leveled output. The slog crate provides a powerful and flexible logging framework that meets these requirements. However, the project does not have a dedicated logger package that uses slog and configures the output format, destination, and filters. This issue suggests the creation of a logger package with slog that can be easily integrated with the project.
Features:
Logger Initialization: Implement a function that initializes the logger with a given configuration file or default settings.
Output Format: Define the log structure and levels, and choose a suitable output format (e.g., JSON, plain text) for the logger.
Output Destination: Choose a suitable output destination (e.g., console, file, network) for the logger, and implement a drain that writes the log messages to the destination.
Output Filters: Implement a mechanism that allows the user to filter the log messages based on the log level, module, or other criteria.
Implementation Guidelines:
Performance: Benchmark and optimize the performance of the logger package, as logging can have a significant impact on the application’s speed and resource consumption. You can use the [testing] and [pprof] packages to measure and improve the performance of your code.
Error Handling: Decide how to handle errors that may occur during logging, such as writing to a closed or unavailable output destination, or formatting an invalid log message. You can use the [errors] package to create and handle errors in a consistent and informative way.
Compatibility: Ensure that your logger package is compatible with the existing log and slog packages, as well as other popular logging packages in the Go ecosystem. You can use the [slog.Handler] interface to adapt different output formats and destinations, and the [slog.Logger] interface to wrap other loggers and add structured fields to them.
Testing: Provide a robust suite of tests to validate the correctness and reliability of the logger package.
Modularity: Design the logger package to be modular and easily extensible, allowing for the addition of new output formats, destinations, or filters in future updates.
Documentation: Provide clear and comprehensive documentation for the logger package, explaining its usage, features, and limitations.
The text was updated successfully, but these errors were encountered:
Why we are not using open-source package like Zap?
Writing the features and more important achieve same performance and allocation rate is hard.
Also what should implement?? the slog package has already JsonHandler for showing result in json format. My question is what is the feature that we looking for?
logger:= slog.New(slog.NewJsonHandler(os.Stdout, nil);
logger.Warn("This is warning", "key", "value")
By the way I create a pull request that use slog package and make it little nicer but slower i think (with color) and this the resutl:
Description:
The project requires a logging system with structured and leveled output. The slog crate provides a powerful and flexible logging framework that meets these requirements. However, the project does not have a dedicated logger package that uses slog and configures the output format, destination, and filters. This issue suggests the creation of a logger package with slog that can be easily integrated with the project.
Features:
Implementation Guidelines:
The text was updated successfully, but these errors were encountered: