Thanks for the comments! :)
The idea behind this logging api is that you can have more than one instance of the logger within your application (that is why there's a logId).
I found that one logger isn't enough, for example: many times I need to log different kind of messages (UI events, server responses, navigation events) and I wanted a way to identify they source. This can be useful when you are building your flash application in layers.
Anyway, here's a class that will do what you wanted:
import LuminicBox.Log.*;
class Log {
public static function log(arg):Void { getInstance().log(arg); }
public static function debug(arg):Void { getInstance().debug(arg); }
public static function info(arg):Void { getInstance().info(arg); }
public static function warn(arg):Void { getInstance().warn(arg); }
public static function error(arg):Void { getInstance().error(arg); }
public static function fatal(arg):Void { getInstance().fatal(arg); }
private static function getInstance():Logger {
if(_instance == undefined) {
_instance = new Logger();
_instance.addPublisher( new TracePublisher() );
_instance.addPublisher( new ConsolePublisher() );
}
return _instance;
}
private static var _instance:Logger;
}
Regards,
Pablo Costantini
On 6/23/05, Scott Whittaker <[EMAIL PROTECTED]> wrote:
Hi Pablo,
One suggestion for your logger: while it is cool to allow singleton access
with Logger.getInstance() it is even cooler if you make the Singleton access
private and call it from within the public static methods of the Logger.
For example, instead of requiring the syntax:
Logger.getInstance().log ("message");
You can shorten it to:
Logger.log ("message");
And inside your public static "log" method make the call to the private
"getInstance" method. I have used this pattern in a few of my static Manager
classes and it works really well and makes your code neater. I've never seen
anyone else do this, I don't know if it is considered "bad form" or anything
but it works great for me :)
Kind regards,
Scott W.
_________________________________________________________________
Need a new job? Check out XtraMSN Careers http://xtramsn.co.nz/careers
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org
_______________________________________________ osflash mailing list [email protected] http://osflash.org/mailman/listinfo/osflash_osflash.org
