Class: ElkLogger
- Includes:
- LoggerInfo
- Defined in:
- lib/elklogger.rb,
lib/elklogger/version.rb
Defined Under Namespace
Modules: LoggerInfo Classes: Configuration
Constant Summary collapse
- SUPER_VERSION =
keep superclass (Logger) version
VERSION- VERSION =
"0.0.7"
Instance Attribute Summary collapse
-
#calling_cname ⇒ Object
readonly
Returns the value of attribute calling_cname.
-
#calling_mname ⇒ Object
readonly
Returns the value of attribute calling_mname.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #format_message(severity, datetime, progname, msg) ⇒ Object
-
#initialize(logdev, shift_age = 0, shift_size = 1048576) ⇒ ElkLogger
constructor
A new instance of ElkLogger.
Methods included from LoggerInfo
#appname, #counter_number, #ipv4_address, #ruby_pid, #thread_name
Constructor Details
#initialize(logdev, shift_age = 0, shift_size = 1048576) ⇒ ElkLogger
Returns a new instance of ElkLogger.
67 68 69 70 71 72 73 |
# File 'lib/elklogger.rb', line 67 def initialize(logdev, shift_age = 0, shift_size = 1048576) @calling_mname = nil # calling method name @calling_cname = nil # calling class name @filename = logdev super(logdev, shift_age, shift_size) end |
Instance Attribute Details
#calling_cname ⇒ Object (readonly)
Returns the value of attribute calling_cname.
65 66 67 |
# File 'lib/elklogger.rb', line 65 def calling_cname @calling_cname end |
#calling_mname ⇒ Object (readonly)
Returns the value of attribute calling_mname.
65 66 67 |
# File 'lib/elklogger.rb', line 65 def calling_mname @calling_mname end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
65 66 67 |
# File 'lib/elklogger.rb', line 65 def filename @filename end |
Instance Method Details
#format_message(severity, datetime, progname, msg) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/elklogger.rb', line 75 def (severity, datetime, progname, msg) { :body => msg.to_s, :head => { :app => appname, :level => severity, :counter => counter_number, :tname => thread_name || filename.to_s.split('/').last.to_s.gsub(/\.log\.elk$/, ''), :pid => ruby_pid, :mname => calling_mname, :cname => calling_cname, :ip => ipv4_address.to_s }, :timestamp => datetime.to_datetime.strftime("%Q").to_i }.to_json + "\n" end |