Module: Thin::Logging
- Included in:
- Command, Connection, Controllers::Controller, Server
- Defined in:
- lib/thin/logging.rb
Overview
To be included in classes to allow some basic logging that can be silenced (Logging.silent=
) or made more verbose. Logging.debug=
: log all error backtrace and messages
logged with +debug+.
Logging.trace=
: log all raw request and response and
messages logged with +trace+.
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(e = $!) ⇒ 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(e = $!) ⇒ Object
Log an error backtrace if debugging is activated.
-
#silent ⇒ Object
Global silencer methods.
- #silent=(value) ⇒ Object
-
#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
11 12 13 |
# File 'lib/thin/logging.rb', line 11 def debug=(value) @debug = value end |
.silent=(value) ⇒ Object (writeonly)
Sets the attribute silent
11 12 13 |
# File 'lib/thin/logging.rb', line 11 def silent=(value) @silent = value end |
.trace=(value) ⇒ Object (writeonly)
Sets the attribute trace
11 12 13 |
# File 'lib/thin/logging.rb', line 11 def trace=(value) @trace = value end |
Class Method Details
.debug(msg = nil) ⇒ Object (writeonly)
Log a message to the console if debugging is activated
41 42 43 |
# File 'lib/thin/logging.rb', line 41 def debug(msg=nil) log msg || yield if Logging.debug? end |
.debug? ⇒ Boolean
14 |
# File 'lib/thin/logging.rb', line 14 def debug?; !@silent && @debug end |
.log(msg) ⇒ Object
Log a message to the console
27 28 29 |
# File 'lib/thin/logging.rb', line 27 def log(msg) puts msg unless Logging.silent? end |
.log_error(e = $!) ⇒ Object
Log an error backtrace if debugging is activated
48 49 50 |
# File 'lib/thin/logging.rb', line 48 def log_error(e=$!) debug "#{e}\n\t" + e.backtrace.join("\n\t") end |
.silent? ⇒ Boolean
15 |
# File 'lib/thin/logging.rb', line 15 def silent?; @silent end |
.trace(msg = nil) ⇒ Object (writeonly)
Log a message to the console if tracing is activated
34 35 36 |
# File 'lib/thin/logging.rb', line 34 def trace(msg=nil) log msg || yield if Logging.trace? end |
.trace? ⇒ Boolean
13 |
# File 'lib/thin/logging.rb', line 13 def trace?; !@silent && @trace end |
Instance Method Details
#debug(msg = nil) ⇒ Object
Log a message to the console if debugging is activated
41 42 43 |
# File 'lib/thin/logging.rb', line 41 def debug(msg=nil) log msg || yield if Logging.debug? end |
#log(msg) ⇒ Object
Log a message to the console
27 28 29 |
# File 'lib/thin/logging.rb', line 27 def log(msg) puts msg unless Logging.silent? end |
#log_error(e = $!) ⇒ Object
Log an error backtrace if debugging is activated
48 49 50 |
# File 'lib/thin/logging.rb', line 48 def log_error(e=$!) debug "#{e}\n\t" + e.backtrace.join("\n\t") end |
#silent ⇒ Object
Global silencer methods
19 20 21 |
# File 'lib/thin/logging.rb', line 19 def silent Logging.silent? end |