Module: RubySmart::SimpleLogger::Extensions::Logs
- Included in:
- Logger
- Defined in:
- lib/ruby_smart/simple_logger/extensions/logs.rb
Instance Method Summary collapse
-
#log_stats ⇒ Hash
returns a hash with total amounts per logged type (key).
-
#logs ⇒ Array
returns the logdev logs.
-
#logs_to_h ⇒ Hash
transforms the logs-array into a hash of logs, grouped by level (:error, :success, ...).
Instance Method Details
#log_stats ⇒ Hash
returns a hash with total amounts per logged type (key)
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 |
#logs ⇒ Array
returns the logdev logs
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_h ⇒ Hash
transforms the logs-array into a hash of logs, grouped by level (:error, :success, ...)
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 |