Module: Gecode::LoggingLayer

Defined in:
lib/gecoder/bindings.rb

Overview

Describes a layer that delegates to GecodeRaw only after having logged the call.

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object



36
37
38
# File 'lib/gecoder/bindings.rb', line 36

def self.const_missing(name)
  ::GecodeRaw.const_get(name)
end

.loggerObject

Gets the logger, or creates one if none exists.



41
42
43
44
45
46
47
# File 'lib/gecoder/bindings.rb', line 41

def self.logger
  return @logger unless @logger.nil?
  file = open('gecoder.log', File::WRONLY | File::APPEND | File::CREAT)
  @logger = ::Logger.new(file)
  @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
  @logger
end

.method_missing(name, *args) ⇒ Object



31
32
33
34
# File 'lib/gecoder/bindings.rb', line 31

def self.method_missing(name, *args)
  logger.info{ "#{name}(#{args.join(', ')})" }
  ::GecodeRaw.send(name, *args)
end