Class: RFlow::Logger
- Inherits:
-
Object
- Object
- RFlow::Logger
- Extended by:
- Forwardable
- Includes:
- Log4r
- Defined in:
- lib/rflow/logger.rb
Constant Summary collapse
- LOG_PATTERN_FORMAT =
'%-5l [%d] %x (%-5p) - %M'
- DATE_METHOD =
'xmlschema(6)'
- LOG_PATTERN_FORMATTER =
PatternFormatter.new :pattern => LOG_PATTERN_FORMAT, :date_method => DATE_METHOD
Instance Attribute Summary collapse
-
#context_width ⇒ Object
Returns the value of attribute context_width.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(config, include_stdout = false) ⇒ Logger
constructor
A new instance of Logger.
- #level=(level) ⇒ Object
- #reconfigure(config, include_stdout = false) ⇒ Object
- #reopen ⇒ Object
- #toggle_log_level ⇒ Object
Constructor Details
#initialize(config, include_stdout = false) ⇒ Logger
Returns a new instance of Logger.
27 28 29 |
# File 'lib/rflow/logger.rb', line 27 def initialize(config, include_stdout = false) reconfigure(config, include_stdout) end |
Instance Attribute Details
#context_width ⇒ Object
Returns the value of attribute context_width.
17 18 19 |
# File 'lib/rflow/logger.rb', line 17 def context_width @context_width end |
Instance Method Details
#close ⇒ Object
53 54 55 |
# File 'lib/rflow/logger.rb', line 53 def close Outputter['rflow.log_file'].close end |
#level=(level) ⇒ Object
57 58 59 |
# File 'lib/rflow/logger.rb', line 57 def level=(level) internal_logger.level = LNAMES.index(level.to_s) || level end |
#reconfigure(config, include_stdout = false) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rflow/logger.rb', line 31 def reconfigure(config, include_stdout = false) @log_file_path = config['rflow.log_file_path'] @log_level = config['rflow.log_level'] || 'WARN' @log_name = if config['rflow.application_name']; config['rflow.application_name'] elsif log_file_path; File.basename(log_file_path) else ''; end establish_internal_logger hook_up_logfile hook_up_stdout if include_stdout register_logging_context internal_logger end |
#reopen ⇒ Object
46 47 48 49 50 51 |
# File 'lib/rflow/logger.rb', line 46 def reopen # TODO: Make this less of a hack, although Log4r doesn't support # it, so it might be permanent log_file = Outputter['rflow.log_file'].instance_variable_get(:@out) File.open(log_file.path, 'a') { |tmp_log_file| log_file.reopen(tmp_log_file) } end |
#toggle_log_level ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/rflow/logger.rb', line 61 def toggle_log_level original_log_level = LNAMES[internal_logger.level] new_log_level = (original_log_level == 'DEBUG' ? log_level : 'DEBUG') internal_logger.warn "Changing log level from #{original_log_level} to #{new_log_level}" internal_logger.level = LNAMES.index new_log_level end |