Modules as Singletons
module ModuleBasedLogger ERROR = 1 WARNING = 2 INFO = 3 @@log = File.open("log.txt", "w") @@level = WARNING def self.error(msg) @@log.puts(msg) @@log.flush end end ModuleBasedLogger.error('Computer wins chess game.')