Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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