You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
721 B

require 'dotenv'
# Hot Live Constants
module LiveConstants
HOTENV = {} # rubocop:disable Style/MutableConstant
LOGGER = SemanticLogger[to_s]
class << self
def stimulus_debug = load_boolean('STIMULUS_DEBUG', false)
def log_active_record = load_boolean('LOG_ACTIVE_RECORD', true)
def log_action_view = load_boolean('LOG_ACTION_VIEW', true)
def reload!
HOTENV.replace Dotenv.parse
# LOGGER.warn 'reloaded!'
ActiveRecord::Base.logger.level = log_active_record ? :debug : :fatal
ActionView::Base.logger.level = log_action_view ? :debug : :fatal
end
private
def load_boolean(key, default) = HOTENV.fetch(key, default).to_s.downcase == 'true'
end
reload!
end