Class: XClarityClient::XClarityLogger
- Inherits:
-
Object
- Object
- XClarityClient::XClarityLogger
- Defined in:
- lib/utils/logger.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
- #error(header, msg) ⇒ Object
- #info(header, msg) ⇒ Object
-
#initialize(global_log = nil) ⇒ XClarityLogger
constructor
A new instance of XClarityLogger.
Constructor Details
#initialize(global_log = nil) ⇒ XClarityLogger
Returns a new instance of XClarityLogger.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/utils/logger.rb', line 8 def initialize(global_log=nil) # This block below looks for a log in the project which uses # this client or a defined log coming from initialize param. # If none of these logs exists, is created a log by default. @log = $lenovo_log ||= $log ||= global_log if not @log FileUtils::mkdir_p 'logs' file = File.open('logs/lxca_client.log', 'a+') file.sync = true @log = Logger.new file end end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
6 7 8 |
# File 'lib/utils/logger.rb', line 6 def log @log end |
Instance Method Details
#error(header, msg) ⇒ Object
28 29 30 31 |
# File 'lib/utils/logger.rb', line 28 def error(header, msg) @log.level = Logger::ERROR @log.error "[#{header}] - #{msg}" end |
#info(header, msg) ⇒ Object
23 24 25 26 |
# File 'lib/utils/logger.rb', line 23 def info(header, msg) @log.level = Logger::DEBUG @log.info "[#{header}] - #{msg}" end |