Class: Centralpos::Core::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/centralpos/core/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Logger

Receives a hash with keys ‘log`, `pretty_print_xml` and `log_level`. `log_level` can be :info, :debug, :warn, :error or :fatal

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :log (Boolean)
  • :pretty_print_xml (Boolean)
  • :log_level (Symbol)


13
14
15
16
17
# File 'lib/centralpos/core/logger.rb', line 13

def initialize(opts = {})
  @log = opts[:log] || false
  @pretty_print_xml = opts[:pretty_print_xml] || false
  @log_level = opts[:log_level] || :info
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



4
5
6
# File 'lib/centralpos/core/logger.rb', line 4

def log
  @log
end

#log_levelObject

Returns the value of attribute log_level.



4
5
6
# File 'lib/centralpos/core/logger.rb', line 4

def log_level
  @log_level
end

#pretty_print_xmlObject

Returns the value of attribute pretty_print_xml.



4
5
6
# File 'lib/centralpos/core/logger.rb', line 4

def pretty_print_xml
  @pretty_print_xml
end

Class Method Details

.optionsObject



30
31
32
33
# File 'lib/centralpos/core/logger.rb', line 30

def self.options
  @logger ||= Centralpos::Core::Logger.new
  @logger.logger_options
end

.options=(opts = {}) ⇒ Object



26
27
28
# File 'lib/centralpos/core/logger.rb', line 26

def self.options=(opts = {})
  @logger = Centralpos::Core::Logger.new(opts)
end

Instance Method Details

#logger_optionsHash

Returns a hash with the logging options for Savon.

Returns:

  • (Hash)


22
23
24
# File 'lib/centralpos/core/logger.rb', line 22

def logger_options
  { log: log, pretty_print_xml: pretty_print_xml, log_level: log_level }
end