Module: Collective::Log

Included in:
Configuration, Monitor, Pool, Utilities::LogObserver
Defined in:
lib/collective/log.rb

Instance Method Summary collapse

Instance Method Details

#format_for_logging(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/collective/log.rb', line 8

def format_for_logging( *args )
  message = [
    #(Time.now.strftime "%Y%m%d%H%M%S"),
    Time.now.to_i,
    " [",
    Process.pid,
    (Thread.current[:name] || Thread.current.object_id unless Thread.current == Thread.main),
    "] ",
    args.join(", "),
    "\n"
  ].compact.join
end

#log(*args) ⇒ Object



3
4
5
6
# File 'lib/collective/log.rb', line 3

def log( *args )
  logger.print(format_for_logging(*args))
  logger.flush
end

#loggerObject



21
22
23
# File 'lib/collective/log.rb', line 21

def logger
  @logger ||= STDOUT
end

#logger=(other) ⇒ Object



25
26
27
# File 'lib/collective/log.rb', line 25

def logger=( other )
  @logger = other
end