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

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.debug=(value) ⇒ Object (writeonly)

Sets the attribute debug

Parameters:

  • value

    the value to set the attribute debug to.



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

Parameters:

  • value

    the value to set the attribute silent to.



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

Parameters:

  • value

    the value to set the attribute trace to.



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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


11
# File 'lib/omf-web/thin/logging.rb', line 11

def trace?;  !@silent && @trace  end

Instance Method Details

#_loggerObject



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