Module: EtcdTools::Watchdog::Util::Logger

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

Instance Method Summary collapse

Instance Method Details

#debug(message) ⇒ Object



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

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



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

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



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

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