Class: Dataflow::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/dataflow/logger.rb

Defined Under Namespace

Classes: LoggerImpl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix:, use_notifications: false) ⇒ Logger

Returns a new instance of Logger.



7
8
9
10
11
# File 'lib/dataflow/logger.rb', line 7

def initialize(prefix:, use_notifications: false)
  @prefix = prefix
  @use_notifications = use_notifications
  @@impl = LoggerImpl.new
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



4
5
6
# File 'lib/dataflow/logger.rb', line 4

def prefix
  @prefix
end

#use_notificationsObject

Returns the value of attribute use_notifications.



5
6
7
# File 'lib/dataflow/logger.rb', line 5

def use_notifications
  @use_notifications
end

Instance Method Details

#log(str) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/dataflow/logger.rb', line 13

def log(str)
  return if ENV['RACK_ENV'] == 'test'
  now = DateTime.now.strftime('%y-%m-%d %H:%M:%S')
  message = "[#{now}] #{prefix} :: #{str}"
  logger_impl = @@impl
  logger_impl.log(message)
end