Sha256: 641d6f4a2dc7555d20cdbfc5de8fba01de82957f6faa36cacb300ee3274a7581
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'berkeley_library/logging/env' require 'berkeley_library/logging/events' require 'berkeley_library/logging/formatters' require 'berkeley_library/logging/loggers' module BerkeleyLibrary module Logging class Configurator class << self # Applies the log configuration to the specified Rails config. # # @return [BerkeleyLibrary::Logging::Logger] the configured logger def configure(config) configure_lograge(config) Loggers.new_default_logger(config).tap do |logger| logger.info("Custom logger initialized for environment #{Logging.env.inspect}") configure_webpacker(logger) config.logger = logger end end private def configure_lograge(config) return unless config.respond_to?(:lograge) lograge_config = config.lograge custom_options = Events.extract_data_for_lograge(lograge_config) lograge_config.tap do |lograge| lograge.enabled = true lograge.custom_options = custom_options lograge.formatter = Formatters.lograge_formatter end end def configure_webpacker(logger) return unless defined?(::Webpacker) logger.info('Using custom logger for Webpacker') ::Webpacker::Instance.logger = logger end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
berkeley_library-logging-0.2.7 | lib/berkeley_library/logging/configurator.rb |