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



16
17
18
# File 'lib/gecoder/bindings.rb', line 16

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

.loggerObject

Gets the logger, or creates one if none exists.



21
22
23
24
25
26
27
# File 'lib/gecoder/bindings.rb', line 21

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



11
12
13
14
# File 'lib/gecoder/bindings.rb', line 11

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