logger.cr

Crystal logger

logger.cr

Crystal logger

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      logger:
        github: pyer/logger.cr
    
  2. Run shards install

Usage

The Logger class provides a simple logging utility that you can use to output messages.

The messages have associated levels, such as INFO or ERROR that indicate their importance. You can then give the Logger a level, and only messages at that level or higher will be printed.

For instance, in a production system, you may have your Logger set to INFO or even WARN. When you are developing the system, however, you probably want to know about the program’s internal state, and would set the Logger to DEBUG.

The log level can be set with the environment variable LOG_LEVEL. Values are TRACE, DEBUG, INFO, NOTICE, WARN, ERROR, FATAL and NONE.

Default level is INFO.

Example

require "logger"

log = Logger.new(STDOUT)
log.level = Logger::WARN

# or
log = Logger.new(STDOUT, level: Logger::WARN)

log.debug("Created logger")
log.info("Program started")
log.warn("Nothing to do!")
Repository

logger.cr

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 1
  • about 2 hours ago
  • September 22, 2026
License

MIT License

Links
Synced at

Wed, 30 Sep 2026 20:34:13 GMT

Languages