00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * デバッグ出力ヘッダ 00022 * @author Junpee 00023 */ 00024 #ifndef DEBUG_OUTPUT_H_ 00025 #define DEBUG_OUTPUT_H_ 00026 00027 //------------------------------------------------------------------------------ 00028 // デバッグ時 00029 #ifdef _DEBUG 00030 00031 /** 00032 * デバッグ出力の初期化 00033 */ 00034 #define DebugOutInitialize() ::Lamp::DebugOutput::initialize() 00035 00036 /** 00037 * デバッグ出力の後始末 00038 */ 00039 #define DebugOutFinalize() ::Lamp::DebugOutput::finalize() 00040 00041 00042 /** 00043 * デバッグ出力 00044 * 00045 * デバッグ時にprintfと同じ構文で呼び出すと、デバッグ出力にメッセージを出力します。 00046 * <pre> 00047 * サンプルコード 00048 * 00049 * // デバッグ時、デバッグ出力に「Hoge 1 2.0」と出力して改行する。 00050 * DebugOut("Hoge %d %.1f\n", 1, 2.f); 00051 * </pre> 00052 */ 00053 #define DebugOut ::Lamp::DebugOutput::print 00054 00055 /** 00056 * 線の出力 00057 * 00058 * デバッグ時にデバッグ出力に線を出力し、改行します。 00059 */ 00060 #define DebugOutLine() ::Lamp::DebugOutput::print("------------------------------"\ 00061 "--------------------------------------------------\n") 00062 00063 /** 00064 * 太い線の出力 00065 * 00066 * デバッグ時にデバッグ出力に太い線を出力し、改行します。 00067 */ 00068 #define DebugOutThickLine() ::Lamp::DebugOutput::print("##############################"\ 00069 "##################################################\n") 00070 00071 namespace Lamp{ 00072 00073 class String; 00074 00075 /** 00076 * デバッグ出力クラス 00077 * 00078 * デバッグ出力の実装クラスです。 00079 */ 00080 class DebugOutput{ 00081 public: 00082 /** 00083 * 初期化 00084 * @param fileName デバッグログファイル名。NULLだとログを残しません。 00085 */ 00086 static void initialize(const char* fileName = "LampDebugLog.txt"); 00087 00088 /** 00089 * 後始末 00090 */ 00091 static void finalize(); 00092 00093 /** 00094 * デバッグ出力 00095 * 00096 * 可変長引数に対応したデバッグ出力メソッド。 00097 * @param format フォーマット 00098 * @param ... 可変長引数 00099 * @return 出力文字数 00100 */ 00101 static int print(const char* format, ...); 00102 00103 /** 00104 * デバッグ出力 00105 * @param string 文字列 00106 * @return 出力文字数 00107 */ 00108 static int print(const String& string); 00109 00110 private: 00111 // コンストラクタ隠蔽 00112 DebugOutput(); 00113 00114 // ロガー 00115 static Logger* logger_; 00116 }; 00117 00118 } // End of namespace Lamp 00119 00120 //------------------------------------------------------------------------------ 00121 // 非デバッグ時 00122 #else // ! _DEBUG 00123 00124 // デバッグ出力の初期化ダミー 00125 #define DebugOutInitialize() 00126 00127 // デバッグ出力の後始末ダミー 00128 #define DebugOutFinalize() 00129 00130 /// 出力ダミー 00131 #define DebugOut 00132 00133 /// 線の出力ダミー 00134 #define DebugOutLine() 00135 00136 /// 太い線の出力ダミー 00137 #define DebugOutThickLine() 00138 00139 #endif// End of _DEBUG 00140 00141 //------------------------------------------------------------------------------ 00142 #endif // End of DEBUG_OUTPUT_H_ 00143 //------------------------------------------------------------------------------