diff --git a/compose.yml b/compose.yml index 33e7a1d..5d8ba9b 100644 --- a/compose.yml +++ b/compose.yml @@ -32,6 +32,7 @@ services: - "DIRECT_URLS_TO_SOLR_REPLICAS=http://solr:8983 http://solr:8983" - MANUALLY_BUILD_SUGGESTERS=true - PAUSE_TIME=10 + - RAILS_LOG_TO_STDOUT=true env_file: - path: .app.env required: false diff --git a/config/application.rb b/config/application.rb index 3691c3b..3db6042 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,17 +65,12 @@ class Application < Rails::Application ip: :remote_ip, } + config.rails_semantic_logger.add_file_appender = false config.rails_semantic_logger.console_logger = false config.rails_semantic_logger.quiet_assets = true - config.rails_semantic_logger.format = :json - - config.rails_semantic_logger.add_file_appender = false - # config.semantic_logger.add_appender(file_name: "log/#{Rails.env}.log", level: :info) - config.semantic_logger.add_appender(file_name: "log/#{Rails.env}.json", formatter: JSON_FORMATTER, level: :info) + config.colorize_logging = false - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + config.semantic_logger.add_appender(io: $stdout, formatter: :logfmt, level: :info) # Done with all that? Now pull in local Ettin-based configuration. diff --git a/config/environments/production.rb b/config/environments/production.rb index 3b058da..d6fb04d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -80,11 +80,11 @@ # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') # - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new($stdout) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end + # if ENV["RAILS_LOG_TO_STDOUT"].present? + # logger = ActiveSupport::Logger.new($stdout) + # logger.formatter = config.log_formatter + # config.logger = ActiveSupport::TaggedLogging.new(logger) + # end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false diff --git a/config/load_local_config.rb b/config/load_local_config.rb index d1fb2ed..059cf18 100644 --- a/config/load_local_config.rb +++ b/config/load_local_config.rb @@ -8,9 +8,7 @@ module Dromedary class << self extend TTLMemoizeable - def logger - Rails.logger || MedInstaller::Logger::LOGGER - end + include MedInstaller::Logger # For whatever historical reasons, this uses the Ettin gem to load # up yaml files. The list of places it looks are: @@ -35,7 +33,6 @@ def config def hyp_to_bibid collection = Dromedary::Services[:solr_current_collection] - Rails.logger.warn "################# Fetching HyperBib ########################" MedInstaller::HypToBibId.get_from_solr(collection: collection) end diff --git a/lib/med_installer/logger.rb b/lib/med_installer/logger.rb index 2be2e28..b0dd204 100644 --- a/lib/med_installer/logger.rb +++ b/lib/med_installer/logger.rb @@ -8,16 +8,16 @@ def process_info end end - Formatter = MEDFormatter.new(time_format: "%Y-%m-%d:%H:%M:%S") - SemanticLogger.add_appender(io: $stderr, level: :info, formatter: Formatter) - LOGGER = SemanticLogger["Dromedary"] + LOGGER = if defined? Rails + Rails.logger + else + SemanticLogger.add_appender(io: $stderr, level: :info, formatter: :logfmt) + SemanticLogger["MED Indexer"] + end + def logger - if defined? Rails - Rails.logger - else - LOGGER - end + LOGGER end end end