Loggingライブラリ、ThunderBolt
9月 25th, 2008Loggingライブラリとして、ThunderBoltを利用することにしました。
準備はsourceフォルダの org\osflash\thunderbolt\Logger.asをコピーして、インポートするだけです。
あとは、以下のように呼び出して利用できます。
Logger.debug("○○○", 1, 2, 3, ...);
Logger.info("○○○");
Logger.error("○○○");
Logger.warn("○○○");
また、hideプロパティーで出力のOn/Offができます。
Logger.hide = true;
Logger.info("これは出力されない。");
Logger.hide = false;
あとおまけで、メモリの使用状況を確認できます。
Logger.info(Logger.memorySnapshot());
これは、System.totalMemory を呼んでるだけですけどね。
KBとMBの単位で出力してくれるので、重宝します。
以下、Logger.memorySnapshot() のソース部分
public static function memorySnapshot():String {
var currentMemValue: uint = System.totalMemory;
var message: String = "Memory Snapshot: "
+ Math.round(currentMemValue / 1024 / 1024 * 100) / 100
+ " MB ("
+ Math.round(currentMemValue / 1024)
+ " kb)";
return message;
}