lib/finapps/utils/logging.rb in finapps-0.22.4.pre vs lib/finapps/utils/logging.rb in finapps-1.0.0

- old
+ new

@@ -1,17 +1,17 @@ module FinApps module Logging SEVERITY_LABEL = %w(DEBUG INFO WARN ERROR FATAL UNKNOWN) - PROTECTED_KEYS = %w(login password password_confirm password1 token) + PROTECTED_KEYS = %w(login login1 password password1 password_confirm token) FORMAT = "\033[%sm[%s#%d] %5s -- %s: %s\033[0m\n" FORMAT_TAG = "\033[%sm[%s#%d] %5s -- %s: %s %s\033[0m\n" SEVERITY_COLOR_MAP = {:debug => '0', :info => '32', :warn => '33', :error => '31', :fatal => '31', :unknown => '0;37'} class << self; - attr_accessor :tag; + attr_accessor :tag, :level; end def logger=(logger) @logger = logger end @@ -21,24 +21,24 @@ @logger ||= begin require 'logger' unless defined?(::Logger) ::Logger.new(STDOUT).tap do |log| log.progname = "#{self.class.to_s}" + log.level = Logging.level if Logging.level.present? log.formatter = proc do |severity, time, progname, msg| Logging.tag.present? ? FORMAT_TAG % [severity_to_color(severity), format_datetime(time), $$, severity, progname, Logging.tag.to_s, msg2str(msg)] : FORMAT % [severity_to_color(severity), format_datetime(time), $$, severity, progname, msg2str(msg)] + end end end end - def set_up_logger_level(logger_level) - unless logger_level.blank? || logger.level == logger_level - logger.info "##{__method__.to_s} => Setting logger level to #{SEVERITY_LABEL[logger_level]}" - logger.level = logger_level - end + def logger_config(config) + Logging.tag= config[:logger_tag] if config[:logger_tag].present? + Logging.level = config[:log_level] if config[:log_level].present? end # noinspection SpellCheckingInspection def set_up_logger_session_params(uuid, session_id) if uuid.present? || session_id.present?