Module: RubySmart::SimpleLogger::Extensions::Logs

Included in:
Logger
Defined in:
lib/ruby_smart/simple_logger/extensions/logs.rb

Instance Method Summary collapse

Instance Method Details

#log_statsHash

returns a hash with total amounts per logged type (key)

Returns:

  • (Hash)


26
27
28
# File 'lib/ruby_smart/simple_logger/extensions/logs.rb', line 26

def log_stats
  logs_to_h.reduce({}) { |m, (sev, logs)| m[sev] = logs.count; m }
end

#logsArray

returns the logdev logs

Returns:

  • (Array)


9
10
11
12
# File 'lib/ruby_smart/simple_logger/extensions/logs.rb', line 9

def logs
  return [] unless logdev.respond_to?(:logs)
  logdev.logs
end

#logs_to_hHash

transforms the logs-array into a hash of logs, grouped by level (:error, :success, ...)

Returns:

  • (Hash)

    logs



16
17
18
19
20
21
22
# File 'lib/ruby_smart/simple_logger/extensions/logs.rb', line 16

def logs_to_h
  logs.reduce({}) do |m, log|
    m[log[0]] ||= []
    m[log[0]] << log[2]
    m
  end
end