From: Robert Klemme Date: 2008-06-23T15:23:17+09:00 Subject: Re: Is it ellegant to use a global variable to store a Logger object? On 23.06.2008 03:29, Suraj Kurapati wrote: > Iņaki Baz Castillo wrote: >> Humm, I don't like adding "include Logging" to every classes I use since >> sometimes I use objects, sometimes classes, so I'd also need to "extend" >> some classes not just "include". > > You could use meta programming to include Logging in all nested classes > and modules of your top-level module: Now things are becoming quite complex. Logging is a global task and thusly some form of global handling is perfectly ok IMHO. Using a global variable has the advantage that you do not collide with instance methods (which you do if you place #debug etc. in all classes either via inheritance, meta programming or other means). IMHO the only bad aspect about the global is that you cannot ensure automatic initialization. An alternative would be to add a single method to Kernel that lazily initializes a Logger instance. My 0.02 EUR. Kind regards robert