I
Iñaki Baz Castillo
Hi, I use Logger class in a programm and since I need to log in lot of=20
different places (into classes, into methods...) I use a global variable in=
=20
this way:
$log =3D Logger.new
$log.debug ...
so I can use $log anywhere in the code. Is it ellegant and "the Ruby way"?
The other possibility I see is creating a class that stores the logger=20
instance into a @@class_variable (@@logger) and call class method anywhere =
in=20
the code:
class MyLogger
@@logger =3D Logger.new
def self.debug(x)
@@logger.debug(x)
end
...
end
MyLogger.debug ...
Which is a more ellegant way? is there other option?
Thanks for any advice I could receive from you.
=20
=2D-=20
I=C3=B1aki Baz Castillo
different places (into classes, into methods...) I use a global variable in=
=20
this way:
$log =3D Logger.new
$log.debug ...
so I can use $log anywhere in the code. Is it ellegant and "the Ruby way"?
The other possibility I see is creating a class that stores the logger=20
instance into a @@class_variable (@@logger) and call class method anywhere =
in=20
the code:
class MyLogger
@@logger =3D Logger.new
def self.debug(x)
@@logger.debug(x)
end
...
end
MyLogger.debug ...
Which is a more ellegant way? is there other option?
Thanks for any advice I could receive from you.
=20
=2D-=20
I=C3=B1aki Baz Castillo