Class: LogjamAgent::SyslogLikeFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/logjam_agent/syslog_like_formatter.rb

Instance Method Summary collapse

Constructor Details

#initializeSyslogLikeFormatter

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, timestamp, progname, msg)
  "#{severity} #{format_time(timestamp)}#{format_host_info(progname)}: #{format_message(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 format_message(msg)
  msg.strip
end

#format_time(timestamp) ⇒ Object



8
9
10
# File 'lib/logjam_agent/syslog_like_formatter.rb', line 8

def format_time(timestamp)
  timestamp.strftime("%b %d %H:%M:%S.#{"%06d" % timestamp.usec}")
end