Class: Elastics::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/elastics/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/elastics/logger.rb', line 9

def initialize(*)
  super
  self.level     = ::Logger::WARN
  self.progname  = 'ELASTICS'
  self.formatter = proc do |severity, datetime, progname, msg|
    elastics_format(severity, msg)
  end
  @debug_variables = true
  @debug_request   = true
  @debug_result    = true
  @curl_format     = false
end

Instance Attribute Details

#curl_formatObject

Returns the value of attribute curl_format.



7
8
9
# File 'lib/elastics/logger.rb', line 7

def curl_format
  @curl_format
end

#debug_requestObject

Returns the value of attribute debug_request.



7
8
9
# File 'lib/elastics/logger.rb', line 7

def debug_request
  @debug_request
end

#debug_resultObject

Returns the value of attribute debug_result.



7
8
9
# File 'lib/elastics/logger.rb', line 7

def debug_result
  @debug_result
end

#debug_variablesObject

Returns the value of attribute debug_variables.



7
8
9
# File 'lib/elastics/logger.rb', line 7

def debug_variables
  @debug_variables
end

Instance Method Details

#elastics_format(severity, msg) ⇒ Object



22
23
24
25
# File 'lib/elastics/logger.rb', line 22

def elastics_format(severity, msg)
  prefix = Dye.dye(" ELASTICS-#{severity} ", "ELASTICS-#{severity}:", :blue, :bold, :reversed) + ' '
  msg.split("\n").map{|l| prefix + l}.join("\n") + "\n"
end