Module: UnionStationHooks::Log

Defined in:
lib/union_station_hooks_core/log.rb

Overview

Provides methods for ‘union_station_*` gems to log internal warnings and debugging messages. This module is not to be used by application developers for the purpose of logging information to Union Station.

Constant Summary collapse

@@debugging =
false
@@warn_callback =
nil
@@debug_callback =
nil

Class Method Summary collapse

Class Method Details

.debug(message) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/union_station_hooks_core/log.rb', line 48

def self.debug(message)
  if @@debugging
    if @@debug_callback
      @@debug_callback.call(message)
    else
      STDERR.puts("[UnionStationHooks] #{message}")
    end
  end
end

.debug_callback=(cb) ⇒ Object



62
63
64
# File 'lib/union_station_hooks_core/log.rb', line 62

def self.debug_callback=(cb)
  @@debug_callback = cb
end

.debugging=(value) ⇒ Object



36
37
38
# File 'lib/union_station_hooks_core/log.rb', line 36

def self.debugging=(value)
  @@debugging = value
end

.warn(message) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/union_station_hooks_core/log.rb', line 40

def self.warn(message)
  if @@warn_callback
    @@warn_callback.call(message)
  else
    STDERR.puts("[UnionStationHooks] #{message}")
  end
end

.warn_callback=(cb) ⇒ Object



58
59
60
# File 'lib/union_station_hooks_core/log.rb', line 58

def self.warn_callback=(cb)
  @@warn_callback = cb
end