Module: Logging

Included in:
Bluth::ScheduleWorker, Bluth::Worker
Defined in:
lib/daemonizing.rb

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.



179
180
181
# File 'lib/daemonizing.rb', line 179

def debug=(value)
  @debug = value
end

.silent=(value) ⇒ Object (writeonly)

Sets the attribute silent

Parameters:

  • value

    the value to set the attribute silent to.



179
180
181
# File 'lib/daemonizing.rb', line 179

def silent=(value)
  @silent = value
end

.trace=(value) ⇒ Object (writeonly)

Sets the attribute trace

Parameters:

  • value

    the value to set the attribute trace to.



179
180
181
# File 'lib/daemonizing.rb', line 179

def trace=(value)
  @trace = value
end

Class Method Details

.debug(msg = nil) ⇒ Object (writeonly)

Log a message to the console if debugging is activated



209
210
211
# File 'lib/daemonizing.rb', line 209

def debug(msg=nil)
  log msg || yield if Logging.debug?
end

.debug?Boolean

Returns:

  • (Boolean)


182
# File 'lib/daemonizing.rb', line 182

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

.log(msg) ⇒ Object

Log a message to the console



195
196
197
# File 'lib/daemonizing.rb', line 195

def log(msg)
  puts msg unless Logging.silent?
end

.log_error(e = $!) ⇒ Object

Log an error backtrace if debugging is activated



216
217
218
# File 'lib/daemonizing.rb', line 216

def log_error(e=$!)
  debug "#{e}\n\t" + e.backtrace.join("\n\t")
end

.silent?Boolean

Returns:

  • (Boolean)


183
# File 'lib/daemonizing.rb', line 183

def silent?;  @silent            end

.trace(msg = nil) ⇒ Object (writeonly)

Log a message to the console if tracing is activated



202
203
204
# File 'lib/daemonizing.rb', line 202

def trace(msg=nil)
  log msg || yield if Logging.trace?
end

.trace?Boolean

Returns:

  • (Boolean)


181
# File 'lib/daemonizing.rb', line 181

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

Instance Method Details

#debug(msg = nil) ⇒ Object

Log a message to the console if debugging is activated



209
210
211
# File 'lib/daemonizing.rb', line 209

def debug(msg=nil)
  log msg || yield if Logging.debug?
end

#log(msg) ⇒ Object

Log a message to the console



195
196
197
# File 'lib/daemonizing.rb', line 195

def log(msg)
  puts msg unless Logging.silent?
end

#log_error(e = $!) ⇒ Object

Log an error backtrace if debugging is activated



216
217
218
# File 'lib/daemonizing.rb', line 216

def log_error(e=$!)
  debug "#{e}\n\t" + e.backtrace.join("\n\t")
end

#silentObject

Global silencer methods



187
188
189
# File 'lib/daemonizing.rb', line 187

def silent
  Logging.silent?
end

#silent=(value) ⇒ Object



190
191
192
# File 'lib/daemonizing.rb', line 190

def silent=(value)
  Logging.silent = value
end

#trace(msg = nil) ⇒ Object

Log a message to the console if tracing is activated



202
203
204
# File 'lib/daemonizing.rb', line 202

def trace(msg=nil)
  log msg || yield if Logging.trace?
end