Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rondinif/dbe240bfe038f6286422928556dd8f43 to your computer and use it in GitHub Desktop.
Save rondinif/dbe240bfe038f6286422928556dd8f43 to your computer and use it in GitHub Desktop.
# see: https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html
LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
LOGGER = Logger.new(STDOUT)
level ||= LOGLEVELS.index ENV.fetch("LOG_LEVEL","WARN") # default to WARN index: 2
level ||= Logger::WARN # FIX default in case of environment LOG_LEVEL value is present but not correct
LOGGER.level = level
# Usage:
# before launching the program:
# $ export LOG_LEVEL=DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment