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



80
81
82
# File 'lib/gecoder/bindings.rb', line 80

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

.loggerObject

Gets the logger, or creates one if none exists.



85
86
87
88
89
90
91
# File 'lib/gecoder/bindings.rb', line 85

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



75
76
77
78
# File 'lib/gecoder/bindings.rb', line 75

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