Skip to content

Levelled logger for Go; wraps the standard logger.

License

Notifications You must be signed in to change notification settings

codemedic/go-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Log

Go Reference license

GoLog adds level-based logging to logger(s) from the standard library and offers means to integrate with other logging libraries. Its API is designed to be expressive with sensible configuration defaults and easy to use.

Features

  • Leveled Logging: Provides Debug, Info, Warning, and Error levels for categorized logging.
  • Customizable Print Level: Default log.Print logs to Debug but can be customized with WithPrintLevel.
  • Syslog Support: Includes a NewSyslog constructor for syslog-based logging.
  • Standard Logger Integration: Handles logging via the standard library logger with customizable behavior.
  • Sublogger Customizations: Supports creating subloggers with WithLevel, WithPrefix, and WithRateLimit for fine-grained control.
  • Options and Configuration: Supports environment-based configuration like WithLevelFromEnv and WithSourceLocationFromEnv.
  • Resource Management: Ensures proper cleanup with Close methods.

Examples

See the documentation for examples of how to use the library.

Advanced Features

Seamless Standard Log Integration

This library ensures compatibility with the standard Go logger by providing log.Print and log.Printf methods that replicate the standard logger's behavior.

While log.Print and log.Printf log at the PrintLevel, their use is discouraged as they lack the control and clarity of leveled logging methods. For better categorization and maintainability, use specific leveled logging methods. If needed, adjust their logging level using WithPrintLevel. Refer to examples here for detailed usage.

Flexible Standard Log Handling

The library automatically processes log lines from the standard Go logger, making it ideal for scenarios where standard library logging is unavoidable, such as third-party libraries or specific functionalities. By default, these logs are assigned the Info level, but you can customize this behavior using WithStdlogSorter.

Explore example usage for WithStdlogSorter.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Levelled logger for Go; wraps the standard logger.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages