Module: EtcdTools::Watchdog::Logger

Included in:
Init
Defined in:
lib/etcd-tools/watchdog/logger.rb

Instance Method Summary collapse

Instance Method Details

#debug(message) ⇒ Object



34
35
36
37
38
39
# File 'lib/etcd-tools/watchdog/logger.rb', line 34

def debug(message)
  @semaphore[:log].synchronize do
    $stdout.puts(Time.now.to_s + ' DEBUG (TID:' + Thread.current.object_id.to_s + ') ' + message.to_s)
    $stdout.flush
  end if @config[:debug]
end

#err(message) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/etcd-tools/watchdog/logger.rb', line 20

def err(message)
  if @config[:debug]
    @semaphore[:log].synchronize do
      $stdout.puts(Time.now.to_s + ' ERROR (TID:' + Thread.current.object_id.to_s + ') ' + message.to_s)
      $stdout.flush
    end
  else
    @semaphore[:log].synchronize do
      $stdout.puts(Time.now.to_s + ' ERROR ' + message.to_s)
      $stdout.flush
    end
  end
end

#info(message) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/etcd-tools/watchdog/logger.rb', line 6

def info(message)
  if @config[:debug]
    @semaphore[:log].synchronize do
      $stdout.puts(Time.now.to_s + ' INFO  (TID:' + Thread.current.object_id.to_s + ') ' + message.to_s)
      $stdout.flush
    end
  else
    @semaphore[:log].synchronize do
      $stdout.puts(Time.now.to_s + ' INFO  ' + message.to_s)
      $stdout.flush
    end
  end
end