Module: FormatLogs::InstanceMethods
- Defined in:
- lib/format_logs.rb
Instance Method Summary collapse
- #add_with_formatting(severity, message = nil, progname = nill, &block) ⇒ Object
- #format(severity, message) ⇒ Object
- #trim_leading_whitespace(m) ⇒ Object
Instance Method Details
#add_with_formatting(severity, message = nil, progname = nill, &block) ⇒ Object
117 118 119 120 121 |
# File 'lib/format_logs.rb', line 117 def add_with_formatting(severity, = nil, progname = nill, &block) return if @level > severity = format(severity, ( || (block && block.call) || progname).to_s) add_without_formatting(severity, , progname) end |
#format(severity, message) ⇒ Object
123 124 125 |
# File 'lib/format_logs.rb', line 123 def format(severity, ) "#{self.class.pid}#{self.class.hostname}#{self.class.}#{self.class.to_color(severity)} - #{trim_leading_whitespace()}" end |
#trim_leading_whitespace(m) ⇒ Object
127 128 129 |
# File 'lib/format_logs.rb', line 127 def trim_leading_whitespace(m) self.class.trim_leading_whitespace? ? m.gsub(/^\s*/,'') : m end |