From: "Iñaki Baz Castillo" Date: 2008-06-27T05:53:52+09:00 Subject: Re: Is it ellegant to use a global variable to store a Logger object? El Jueves, 26 de Junio de 2008, Shot (Piotr Szotkowski) escribió: > module MyProgram >   class Logger >   class << self >     def debug … >       … >     end >   end >   end > end > > This way the global namespace is not cluttered, there are no conflicts > with other programs’ Logger classes/objects, while anywhere in your > program (i.e., anywhere in module MyProgram) you can simply call > > Logger.debug … > > which is the clearest syntax to my eyes. Ok, this seems really ellegant and I've tested that I can call "Logger.debug..." in any submodule/subclass into the program :) Just a question: Logger must use an instance of a class (real class Logger), so to store it I think the best option is using a @@class_variable into Logger module, something like: module MyProgram class MyLogger @@logger = Logger.new(xxxxx,xxxx) class << self def debug(text) @@logger.debug(txt) end end end end Is it ok? Thanks a lot. -- Iñaki Baz Castillo