module ElkLogger::LoggerInfo
Public Instance Methods
appname()
click to toggle source
# File lib/elklogger.rb, line 46 def appname app_name = defined?(Settings) && Settings.try(:elklogger).try(:appname) app_name ? app_name.strip : 'elklogger-not-specified' end
counter_number()
click to toggle source
TODO How to number each line of log files?
# File lib/elklogger.rb, line 52 def counter_number 0 end
ipv4_address()
click to toggle source
def method_name; __callee__; end def class_name; end
# File lib/elklogger.rb, line 35 def ipv4_address # First IPv4 address # ipv4_addr = Socket.ip_address_list.detect { |intf| intf.ipv4_private? } ipv4_addr = Socket.ip_address_list.detect { |intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? # and !intf.ipv4_private? } ipv4_addr.ip_address unless ipv4_addr.nil? end
ruby_pid()
click to toggle source
# File lib/elklogger.rb, line 20 def ruby_pid; $$.to_s; end
thread_name()
click to toggle source
In fact, we should record thread’s name here. But actually we don’t care about thread name in Ruby, we even more care about logfile’s name. So, here we use logfile name instead of thread name. If you want to record thread name, just uncomment the lines in the following method.
# File lib/elklogger.rb, line 28 def thread_name # Thread.current.inspect.match(/Thread:\w+/).to_s end