Class: LogjamAgent::SyslogLikeFormatter
- Inherits:
-
Object
- Object
- LogjamAgent::SyslogLikeFormatter
- Defined in:
- lib/logjam_agent/syslog_like_formatter.rb
Instance Method Summary collapse
- #call(severity, timestamp, progname, msg) ⇒ Object
- #format_host_info(progname) ⇒ Object
- #format_message(msg) ⇒ Object
- #format_time(timestamp) ⇒ Object
-
#initialize ⇒ SyslogLikeFormatter
constructor
A new instance of SyslogLikeFormatter.
Constructor Details
#initialize ⇒ SyslogLikeFormatter
Returns a new instance of SyslogLikeFormatter.
3 4 5 6 |
# File 'lib/logjam_agent/syslog_like_formatter.rb', line 3 def initialize @hostname = LogjamAgent.hostname @app_name = "rails" end |
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
16 17 18 |
# File 'lib/logjam_agent/syslog_like_formatter.rb', line 16 def call(severity, , progname, msg) "#{severity} #{format_time()}#{format_host_info(progname)}: #{(msg)}\n" end |
#format_host_info(progname) ⇒ Object
21 |
# File 'lib/logjam_agent/syslog_like_formatter.rb', line 21 def format_host_info(progname); ""; end |
#format_message(msg) ⇒ Object
12 13 14 |
# File 'lib/logjam_agent/syslog_like_formatter.rb', line 12 def (msg) msg.strip end |
#format_time(timestamp) ⇒ Object
8 9 10 |
# File 'lib/logjam_agent/syslog_like_formatter.rb', line 8 def format_time() .strftime("%b %d %H:%M:%S.#{"%06d" % .usec}") end |