On 28 Mar 2011, at 23:07, Tim Pease wrote:
>=20
> Since you want to reference a single Logger instance globally, perhaps =
a global variable might be useful?
>=20
>  $app_logger =3D Logger.new( ... )
>=20
> If global variables turn your stomach,

I think the general ire against global vars prevented my head from =
considering this :)

> you could create an application level module that contains your logger =
and/or other common objects.
>=20
>  module MyApp
>    extend self
>=20
>    def logger
>      @logger ||=3D Logger.new( ... )
>    end
>  end
>=20
> And now from anywhere in your code you can get the global logger thus
>=20
>  MyApp.logger

I can see I start using this in code a lot, not just for loggers, and =
probably inappropriately, but there you go.


>=20
> Another option to consider is the "logging" gem  =
<https://github.com/TwP/logging>. The advantages of the logging gem are =
the ability to give each class it's own logger and still send all log =
events to the same destination (stdout, file, syslog, or any =
combination). You can then tweak the log level on a class by class =
basis. You can set the log level for one class to "debug" and keep all =
the others at "info" or "warn". This is great when you only need to =
debug a small subset of your application.

I've downloaded it and am giving it a whirl now! Thanks.

Regards,
Iain=