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
-
#debug(msg = nil) ⇒ Object
Log a message to the console if debugging is activated.
-
#log(msg) ⇒ Object
Log a message to the console.
-
#log_error(*args) ⇒ Object
Log an error backtrace if debugging is activated.
-
#trace(msg = nil) ⇒ Object
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
45 46 47 48 |
# File 'lib/omf-web/thin/logging.rb', line 45 def debug(msg=nil) return unless msg (@logger ||= OMF::Base::LObject.new(self.class)).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 ||= OMF::Base::LObject.new(self.class)).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
58 59 60 61 62 |
# File 'lib/omf-web/thin/logging.rb', line 58 def log_error(*args) e = args.last e ||= $! (@logger ||= OMF::Base::LObject.new(self.class)).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
32 33 34 35 36 37 38 39 40 |
# File 'lib/omf-web/thin/logging.rb', line 32 def trace(msg=nil) ### DO NOT COMMIT!!!! Can't figure out where tracing is switched on return ##### return unless msg (@logger ||= OMF::Base::LObject.new(self.class)).debug(msg) end |
.trace? ⇒ Boolean
11 |
# File 'lib/omf-web/thin/logging.rb', line 11 def trace?; !@silent && @trace end |
Instance Method Details
#debug(msg = nil) ⇒ Object
Log a message to the console if debugging is activated
45 46 47 48 |
# File 'lib/omf-web/thin/logging.rb', line 45 def debug(msg=nil) return unless msg (@logger ||= OMF::Base::LObject.new(self.class)).debug(msg) 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 ||= OMF::Base::LObject.new(self.class)).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
58 59 60 61 62 |
# File 'lib/omf-web/thin/logging.rb', line 58 def log_error(*args) e = args.last e ||= $! (@logger ||= OMF::Base::LObject.new(self.class)).error(e) end |
#trace(msg = nil) ⇒ Object
Log a message to the console if tracing is activated
32 33 34 35 36 37 38 39 40 |
# File 'lib/omf-web/thin/logging.rb', line 32 def trace(msg=nil) ### DO NOT COMMIT!!!! Can't figure out where tracing is switched on return ##### return unless msg (@logger ||= OMF::Base::LObject.new(self.class)).debug(msg) end |