From 9cb54641387d11132080c262b874ef097f8bab22 Mon Sep 17 00:00:00 2001 From: Adam Runner Date: Mon, 14 Aug 2023 17:06:20 -0700 Subject: [PATCH] update log level to warn for default and make logging level configurable --- lib/event_source/configure/config.rb | 3 +-- lib/event_source/logging.rb | 2 +- spec/config_helper.rb | 1 + spec/event_source/logging_spec.rb | 1 + spec/rails_app/config/initializers/event_source.rb | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/event_source/configure/config.rb b/lib/event_source/configure/config.rb index 33ffe46d..12817172 100644 --- a/lib/event_source/configure/config.rb +++ b/lib/event_source/configure/config.rb @@ -10,6 +10,7 @@ class Config # TODO: add default for pub_sub_root attr_writer :pub_sub_root, :protocols, :server_configurations + attr_accessor :app_name, :log_level def load_protocols @protocols.each do |protocol| @@ -164,8 +165,6 @@ def delimiter(protocol) '.' end end - - attr_accessor :app_name end end end diff --git a/lib/event_source/logging.rb b/lib/event_source/logging.rb index 5a0b38b7..0fdb0db1 100644 --- a/lib/event_source/logging.rb +++ b/lib/event_source/logging.rb @@ -24,7 +24,7 @@ def logger ::Logging.appenders.rolling_file( 'log/event_source.log', age: 'daily', - level: :debug, + level: EventSource.config.log_level, keep: 7, layout: ::Logging.layouts.json ) diff --git a/spec/config_helper.rb b/spec/config_helper.rb index ff3ea25a..d3d11654 100644 --- a/spec/config_helper.rb +++ b/spec/config_helper.rb @@ -2,6 +2,7 @@ EventSource.configure do |config| config.protocols = %w[amqp http] + config.log_level = :warn end EventSource.initialize! diff --git a/spec/event_source/logging_spec.rb b/spec/event_source/logging_spec.rb index ee947e1e..e2fc0aaf 100644 --- a/spec/event_source/logging_spec.rb +++ b/spec/event_source/logging_spec.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'config_helper' require 'event_source/logging' class LogService diff --git a/spec/rails_app/config/initializers/event_source.rb b/spec/rails_app/config/initializers/event_source.rb index 20e04400..384187c0 100644 --- a/spec/rails_app/config/initializers/event_source.rb +++ b/spec/rails_app/config/initializers/event_source.rb @@ -5,6 +5,7 @@ config.pub_sub_root = Pathname.pwd.join('spec', 'rails_app', 'app', 'event_source') config.server_key = Rails.env.to_sym config.app_name = :enroll + config.log_level = :warn config.servers do |server| # mitc