lib/semantic_logger/logger.rb in semantic_logger-2.15.0 vs lib/semantic_logger/logger.rb in semantic_logger-2.16.0
- old
+ new
@@ -58,16 +58,16 @@
def self.flush
return false unless appender_thread_active?
logger.debug "Flushing appenders with #{queue_size} log messages on the queue"
reply_queue = Queue.new
- queue << { :command => :flush, :reply_queue => reply_queue }
+ queue << {command: :flush, reply_queue: reply_queue}
reply_queue.pop
end
@@lag_check_interval = 5000
- @@lag_threshold_s = 30
+ @@lag_threshold_s = 30
# Returns the check_interval which is the number of messages between checks
# to determine if the appender thread is falling behind
def self.lag_check_interval
@@lag_check_interval
@@ -97,17 +97,17 @@
@@logger = logger
end
# DEPRECATED See SemanticLogger.add_appender
def self.appenders
- warn "[DEPRECATION] `SemanticLogger::Logger.appenders` is deprecated. Please use `SemanticLogger.add_appender` instead."
+ warn '[DEPRECATION] SemanticLogger::Logger.appenders is deprecated. Please use SemanticLogger.add_appender instead.'
SemanticLogger.appenders
end
# DEPRECATED: Please use queue_size instead.
def self.cache_count
- warn "[DEPRECATION] 'SemanticLogger::Logger.cache_count' is deprecated. Please use 'SemanticLogger::Logger.queue_size' instead."
+ warn '[DEPRECATION] SemanticLogger::Logger.cache_count is deprecated. Please use SemanticLogger::Logger.queue_size instead.'
queue_size
end
# Supply a block to be called whenever a metric is seen during benchmark logging
#
@@ -118,11 +118,11 @@
# Example:
# SemanticLogger.on_metric do |log_struct|
# puts "#{log_struct.metric} was received. Log Struct: #{log_struct.inspect}"
# end
def self.on_metric(&block)
- (@@metric_subscribers ||= ThreadSafe::Array.new) << block
+ (@@metric_subscribers ||= ThreadSafe::Array.new) << block
end
############################################################################
protected
@@ -144,21 +144,21 @@
# Internal logger for SemanticLogger
# For example when an appender is not working etc..
# By default logs to STDERR
def self.logger
@@logger ||= begin
- l = SemanticLogger::Appender::File.new(STDERR, :warn)
+ l = SemanticLogger::Appender::File.new(STDERR, :warn)
l.name = name
l
end
end
# Start the appender thread
def self.start_appender_thread
return false if appender_thread_active?
@@appender_thread = Thread.new { appender_thread }
- raise "Failed to start Appender Thread" unless @@appender_thread
+ raise 'Failed to start Appender Thread' unless @@appender_thread
true
end
# Returns true if the appender_thread is active
def self.appender_thread_active?
@@ -171,11 +171,11 @@
# This thread is designed to never go down unless the main thread terminates
# Before terminating at_exit is used to flush all the appenders
#
# Should any appender fail to log or flush, the exception is logged and
# other appenders will still be called
- Thread.current.name = "SemanticLogger::AppenderThread"
+ Thread.current.name = 'SemanticLogger::AppenderThread'
logger.debug "V#{VERSION} Appender thread active"
begin
count = 0
while message = queue.pop
if message.is_a? Log
@@ -206,29 +206,29 @@
logger.error "Appender thread: Failed to flush appender: #{appender.inspect}", exc
end
end
message[:reply_queue] << true if message[:reply_queue]
- logger.debug "Appender thread: All appenders flushed"
+ logger.debug 'Appender thread: All appenders flushed'
else
logger.warn "Appender thread: Ignoring unknown command: #{message[:command]}"
end
end
end
rescue Exception => exception
# This block may be called after the file handles have been released by Ruby
begin
- logger.error "Appender thread restarting due to exception", exception
+ logger.error 'Appender thread restarting due to exception', exception
rescue Exception
nil
end
retry
ensure
@@appender_thread = nil
# This block may be called after the file handles have been released by Ruby
begin
- logger.debug "Appender thread has stopped"
+ logger.debug 'Appender thread has stopped'
rescue Exception
nil
end
end
end
@@ -240,10 +240,10 @@
@@metric_subscribers.each do |subscriber|
begin
subscriber.call(log_struct)
rescue Exception => exc
- logger.error "Exception calling subscriber", exc
+ logger.error 'Exception calling subscriber', exc
end
end
end
end