Class: RestashRails::Logger
- Inherits:
-
Object
- Object
- RestashRails::Logger
- Includes:
- Logger::Severity
- Defined in:
- lib/restash_rails/logger.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
0.010
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#level ⇒ Object
Returns the value of attribute level.
-
#logstash_host ⇒ Object
Returns the value of attribute logstash_host.
-
#logstash_port ⇒ Object
Returns the value of attribute logstash_port.
-
#output_type ⇒ Object
Returns the value of attribute output_type.
-
#outputter ⇒ Object
Returns the value of attribute outputter.
-
#timeout_options ⇒ Object
Returns the value of attribute timeout_options.
Instance Method Summary collapse
-
#initialize(configs) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(configs) ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/restash_rails/logger.rb', line 9 def initialize(configs) self.level = configs[:level] || 'DEBUG' @logstash_host = configs[:host] || '127.0.0.1' #logstash host @logstash_port = configs[:port].to_i || 5960 #logstash port @app_name = configs[:app_name] || ENV['APP_NAME'] || Rails.application.class.name @output_type = (configs[:output_type] || 'tcp').to_s.downcase #TCP connection timeouts in milliseconds if configs[:timeout_options].present? configs[:timeout_options].each{ |k,v| configs[:timeout_options][k] = v.to_f } @timeout_options = configs[:timeout_options] else @timeout_options = { connect_timeout: DEFAULT_TIMEOUT, write_timeout: DEFAULT_TIMEOUT, read_timeout: DEFAULT_TIMEOUT } end set_formatter(configs) @stdout_logger = ::Logger.new(STDOUT) @stdout_logger.formatter = proc do |severity, datetime, progname, msg| "#{msg}\n" end end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def app_name @app_name end |
#formatter ⇒ Object
Returns the value of attribute formatter.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def formatter @formatter end |
#level ⇒ Object
Returns the value of attribute level.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def level @level end |
#logstash_host ⇒ Object
Returns the value of attribute logstash_host.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def logstash_host @logstash_host end |
#logstash_port ⇒ Object
Returns the value of attribute logstash_port.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def logstash_port @logstash_port end |
#output_type ⇒ Object
Returns the value of attribute output_type.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def output_type @output_type end |
#outputter ⇒ Object
Returns the value of attribute outputter.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def outputter @outputter end |
#timeout_options ⇒ Object
Returns the value of attribute timeout_options.
6 7 8 |
# File 'lib/restash_rails/logger.rb', line 6 def @timeout_options end |