Skip to content

Commit

Permalink
Remove all old loggers and start using :logfmt, as per @botimer
Browse files Browse the repository at this point in the history
  • Loading branch information
billdueber committed Jan 23, 2025
1 parent b4bc275 commit d7fb1cc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
1 change: 1 addition & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 5 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions config/load_local_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
16 changes: 8 additions & 8 deletions lib/med_installer/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d7fb1cc

Please sign in to comment.