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

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. require 'dotenv'
  2. # Hot Live Constants
  3. module LiveConstants
  4. HOTENV = {} # rubocop:disable Style/MutableConstant
  5. LOGGER = SemanticLogger[to_s]
  6. class << self
  7. def stimulus_debug = load_boolean('STIMULUS_DEBUG', false)
  8. def log_active_record = load_boolean('LOG_ACTIVE_RECORD', true)
  9. def log_action_view = load_boolean('LOG_ACTION_VIEW', true)
  10. def reload!
  11. HOTENV.replace Dotenv.parse
  12. # LOGGER.warn 'reloaded!'
  13. ActiveRecord::Base.logger.level = log_active_record ? :debug : :fatal
  14. ActionView::Base.logger.level = log_action_view ? :debug : :fatal
  15. end
  16. private
  17. def load_boolean(key, default) = HOTENV.fetch(key, default).to_s.downcase == 'true'
  18. end
  19. reload!
  20. end