Class: Loggerman::Formatters::KeyValueFormatter
- Inherits:
-
Formatter
- Object
- Formatter
- Loggerman::Formatters::KeyValueFormatter
show all
- Defined in:
- lib/loggerman/formatters/key_value_formatter.rb
Instance Method Summary
collapse
Methods inherited from Formatter
#clean_message, #format_message
Instance Method Details
#convert_exception(exception) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/loggerman/formatters/key_value_formatter.rb', line 22
def convert_exception(exception)
message = "exception=#{exception.class}|message=#{exception.message}|"
message << "location=#{exception.backtrace_locations.first}|" unless exception.backtrace_locations.blank?
message << "#{format_message(exception.more_attributes)}|" if exception.respond_to?(:more_attributes) && !exception.more_attributes.blank?
message << "\n#{(exception.backtrace).join("\n")}" unless exception.backtrace.empty?
message.to_s
end
|
#convert_hash(args) ⇒ Object
16
17
18
19
20
|
# File 'lib/loggerman/formatters/key_value_formatter.rb', line 16
def convert_hash(args)
result = ""
args.each { |k,v| result << "#{k}=#{v.inspect}|" }
result.to_s
end
|
#convert_other(message) ⇒ Object
30
31
32
|
# File 'lib/loggerman/formatters/key_value_formatter.rb', line 30
def convert_other(message)
"details=#{message.inspect}|"
end
|
#convert_string(message) ⇒ Object
12
13
14
|
# File 'lib/loggerman/formatters/key_value_formatter.rb', line 12
def convert_string(message)
"details=#{message}|"
end
|
5
6
7
8
9
10
|
# File 'lib/loggerman/formatters/key_value_formatter.rb', line 5
def format_log(severity, timestamp, progname, message)
log_result = "#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}|#{severity}|src=#{Socket.ip_address_list[0].ip_address}|host=#{Socket.gethostname}|"
log_result << "system=#{progname}|" unless progname.blank?
log_result << "#{format_message(message)}" unless message.blank?
log_result.to_s.gsub('||',"|")
end
|