logger.cr
logger.cr
Crystal logger
Installation
-
Add the dependency to your
shard.yml:dependencies: logger: github: pyer/logger.cr -
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!")
logger.cr
- 0
- 0
- 0
- 0
- 1
- about 2 hours ago
- September 22, 2026
MIT License
Wed, 30 Sep 2026 20:34:13 GMT