Module: Thin::Logging
- Defined in:
- lib/omf-web/thin/logging.rb
Overview
Overwrite thin’s logging mix-in to work more nicely with log4r
Class Attribute Summary collapse
-
.debug ⇒ Object
writeonly
Sets the attribute debug.
-
.silent ⇒ Object
writeonly
Sets the attribute silent.
-
.trace ⇒ Object
writeonly
Sets the attribute trace.
Class Method Summary collapse
-
.debug(msg = nil) ⇒ Object
writeonly
Log a message to the console if debugging is activated.
- .debug? ⇒ Boolean
-
.log(msg) ⇒ Object
Log a message to the console.
-
.log_error(*args) ⇒ Object
Log an error backtrace if debugging is activated.
- .silent? ⇒ Boolean
-
.trace(msg = nil) ⇒ Object
writeonly
Log a message to the console if tracing is activated.
- .trace? ⇒ Boolean
Instance Method Summary collapse
- #_logger ⇒ Object
-
#debug(msg = nil) ⇒ Object
(also: #log_debug)
Log a message to the console if debugging is activated.
-
#log(msg) ⇒ Object
(also: #log_info)
Log a message to the console.
-
#log_error(*args) ⇒ Object
Log an error backtrace if debugging is activated.
-
#trace(msg = nil) ⇒ Object
(also: #log_trace)
Log a message to the console if tracing is activated.
Class Attribute Details
.debug=(value) ⇒ Object (writeonly)
Sets the attribute debug
9 10 11 |
# File 'lib/omf-web/thin/logging.rb', line 9 def debug=(value) @debug = value end |
.silent=(value) ⇒ Object (writeonly)
Sets the attribute silent
9 10 11 |
# File 'lib/omf-web/thin/logging.rb', line 9 def silent=(value) @silent = value end |
.trace=(value) ⇒ Object (writeonly)
Sets the attribute trace
9 10 11 |
# File 'lib/omf-web/thin/logging.rb', line 9 def trace=(value) @trace = value end |
Class Method Details
.debug(msg = nil) ⇒ Object (writeonly)
Log a message to the console if debugging is activated
49 50 51 52 |
# File 'lib/omf-web/thin/logging.rb', line 49 def debug(msg=nil) return unless msg _logger.debug(msg) end |
.debug? ⇒ Boolean
12 |
# File 'lib/omf-web/thin/logging.rb', line 12 def debug?; !@silent && @debug end |
.log(msg) ⇒ Object
Log a message to the console
25 26 27 |
# File 'lib/omf-web/thin/logging.rb', line 25 def log(msg) _logger.info(msg) end |
.log_error(*args) ⇒ Object
Log an error backtrace if debugging is activated
Thin 1.3 uses one argument e Thin 1.6 uses two argument message, e
This patch will now support both cases
63 64 65 66 67 |
# File 'lib/omf-web/thin/logging.rb', line 63 def log_error(*args) e = args.last e ||= $! _logger.error(e) end |
.silent? ⇒ Boolean
13 |
# File 'lib/omf-web/thin/logging.rb', line 13 def silent?; @silent end |
.trace(msg = nil) ⇒ Object (writeonly)
Log a message to the console if tracing is activated
35 36 37 38 39 40 41 42 43 |
# File 'lib/omf-web/thin/logging.rb', line 35 def trace(msg=nil) ### DO NOT COMMIT!!!! Can't figure out where tracing is switched on return ##### return unless msg _logger.debug(msg) end |
.trace? ⇒ Boolean
11 |
# File 'lib/omf-web/thin/logging.rb', line 11 def trace?; !@silent && @trace end |
Instance Method Details
#_logger ⇒ Object
71 72 73 |
# File 'lib/omf-web/thin/logging.rb', line 71 def _logger() @logger ||= OMF::Base::Loggable.logger(:thin) end |
#debug(msg = nil) ⇒ Object Also known as: log_debug
Log a message to the console if debugging is activated
49 50 51 52 |
# File 'lib/omf-web/thin/logging.rb', line 49 def debug(msg=nil) return unless msg _logger.debug(msg) end |
#log(msg) ⇒ Object Also known as: log_info
Log a message to the console
25 26 27 |
# File 'lib/omf-web/thin/logging.rb', line 25 def log(msg) _logger.info(msg) end |
#log_error(*args) ⇒ Object
Log an error backtrace if debugging is activated
Thin 1.3 uses one argument e Thin 1.6 uses two argument message, e
This patch will now support both cases
63 64 65 66 67 |
# File 'lib/omf-web/thin/logging.rb', line 63 def log_error(*args) e = args.last e ||= $! _logger.error(e) end |
#trace(msg = nil) ⇒ Object Also known as: log_trace
Log a message to the console if tracing is activated
35 36 37 38 39 40 41 42 43 |
# File 'lib/omf-web/thin/logging.rb', line 35 def trace(msg=nil) ### DO NOT COMMIT!!!! Can't figure out where tracing is switched on return ##### return unless msg _logger.debug(msg) end |