tobyclemson / gmail.com wrote: > Hi, > > Can anyone suggest the best way to pass a Logger object around between > all the classes in an application? > > Currently I have it set in a constant in the top-level but I don't > feel that this is the best way to do it as it couples the code in each > of my classes to the current implementation and makes it difficult for > me to reuse the code elsewhere without first setting up a logger > instance of the same name. > > Thanks, > Toby Actually I use a whole different approach. I do all logging with $stderr.puts(LogMessage.new(message, ...)) (I actually have methods like info, error etc. in Kernel that make the task easier, but that's what's going on). LogMessage has a to_s method, so if the lib is used in an environment that doesn't make use of the LogMessage object, it will be IO#puts which calls to_s on it. Regards Stefan -- Posted via http://www.ruby-forum.com/.