Class: Common::CloudboxLogger
- Inherits:
-
Logger
- Object
- Logger
- Common::CloudboxLogger
- Defined in:
- lib/common/cloudbox_logger.rb
Overview
Helper class to log cloudbox project
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Filename of log file.
-
#path ⇒ Object
readonly
Path where logging is done.
Instance Method Summary collapse
-
#begin_execution(params = nil) ⇒ Object
Format the beginning of a command execution.
-
#begin_main_step(str) ⇒ Object
Format the beginning of a main step.
-
#end_execution ⇒ Object
Format the end of a command execution.
-
#end_main_step(str) ⇒ Object
Format the end of a main step.
-
#initialize(filename, path = '/var/log/cloudbox') ⇒ CloudboxLogger
constructor
Default constructor.
-
#log_http(http) ⇒ Object
Allows to log an http request.
-
#logging_info ⇒ Object
A short string which informs where is located log file.
Constructor Details
#initialize(filename, path = '/var/log/cloudbox') ⇒ CloudboxLogger
Default constructor.
22 23 24 25 26 27 28 29 30 |
# File 'lib/common/cloudbox_logger.rb', line 22 def initialize(filename, path='/var/log/cloudbox') @path = Pathname.new(path) @path.mkpath if !@path.exist? # @todo Make the level of logging configurable in a conf file level = Logger::DEBUG @path = Pathname.new(path + "/" + filename + ".log") @filename = filename super(@path, "monthly", 100 * 1024 * 1024) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Filename of log file.
16 17 18 |
# File 'lib/common/cloudbox_logger.rb', line 16 def filename @filename end |
#path ⇒ Object (readonly)
Path where logging is done.
14 15 16 |
# File 'lib/common/cloudbox_logger.rb', line 14 def path @path end |
Instance Method Details
#begin_execution(params = nil) ⇒ Object
Format the beginning of a command execution.
35 36 37 38 39 40 41 42 43 |
# File 'lib/common/cloudbox_logger.rb', line 35 def begin_execution(params=nil) self.info("############# new execution: #{@filename} #############") if !params.nil? self.info "Argv:" params.each do |arg| self.info " - #{arg}" end end end |
#begin_main_step(str) ⇒ Object
Format the beginning of a main step.
54 55 56 |
# File 'lib/common/cloudbox_logger.rb', line 54 def begin_main_step(str) self.info("#### Main step: #{str}") end |
#end_execution ⇒ Object
Format the end of a command execution.
47 48 49 |
# File 'lib/common/cloudbox_logger.rb', line 47 def end_execution self.info("############# end of execution #{@filename} #############") end |
#end_main_step(str) ⇒ Object
Format the end of a main step.
61 62 63 |
# File 'lib/common/cloudbox_logger.rb', line 61 def end_main_step(str) self.info("#### End of step #{str}") end |
#log_http(http) ⇒ Object
Allows to log an http request.
68 69 70 71 72 73 |
# File 'lib/common/cloudbox_logger.rb', line 68 def log_http(http) if http.instance_of?(Net::HTTP) self.debug("logging http request") http.set_debug_output(self) end end |
#logging_info ⇒ Object
Returns a short string which informs where is located log file.
77 78 79 |
# File 'lib/common/cloudbox_logger.rb', line 77 def logging_info return "You can see log file at '#{@path}'" end |