diff --git a/lib/live/constants.rb b/lib/live/constants.rb index 833b4cc..bf1cf6b 100644 --- a/lib/live/constants.rb +++ b/lib/live/constants.rb @@ -9,5 +9,6 @@ module Live MY_INTEGER = integer 8 MY_STRING = string 'tutu' + MY_STRING2 = string 'toto' end end diff --git a/lib/live/definable.rb b/lib/live/definable.rb index daca760..4e44199 100644 --- a/lib/live/definable.rb +++ b/lib/live/definable.rb @@ -12,7 +12,7 @@ module Live def string(default = '') = define_type_from_callee(caller[0], :string, default) def reload_from_env - logger.debug('reload from env') + # logger.debug('reload from env') changes = [] new_env_values = env_values(cached: false) @@ -28,6 +28,15 @@ module Live private def trigger_rolling_event(changes) + logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╔═╗', before: 1) + changes.each do |change| + kind = change[:kind] + constant = change[:constant] + value = change[:new_value] + logger.warn "Constant #{kind}:#{Semantic::AnsiColors::CLEAR} #{constant} = #{value.ai}" + end + logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╚═╝') + ActiveSupport::Notifications.instrument('rolling.live_constant', changes:) FileUtils.touch(MAIN_CSS) if defined?(RailsLiveReload) # triggering RailsLiveReload rescue StandardError => e @@ -43,7 +52,6 @@ module Live return if new_value == old_value define_value(constant, new_value) - logger.warn "Constant overriden from environment:#{Semantic::AnsiColors::CLEAR} #{constant} = #{new_value.ai}" { kind: :overriden, constant:, type:, old_value:, new_value: } end @@ -54,7 +62,6 @@ module Live type = definition[:type] define_value(constant, new_value) - logger.warn "Constant restored:#{Semantic::AnsiColors::CLEAR} #{constant} = #{new_value.ai}" { kind: :restored, constant:, type:, old_value:, new_value: } end @@ -64,7 +71,7 @@ module Live @env_values = Dotenv.parse(*Dotenv::Rails.files) end - def logger = @logger ||= SemanticLogger[self] + def logger = @logger ||= SemanticLogger[to_s.underscore] def definitions = @definitions ||= {} def define_value(constant, value)