Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Logger.h

Go to the documentation of this file.
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 
00025 #ifndef LOGGER_H_
00026 #define LOGGER_H_
00027 
00028 namespace Lamp{
00029 
00030 class TextFileWriter;
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * ロガー
00035  */
00036 class Logger{
00037 public:
00038     /// ログの出力レベル
00039     enum LogLevel{
00040         /// ログを出さない
00041         zeroLevel = 0,
00042         /// 最低限のログをだす
00043         fewLevel = 1,
00044         /// 普通のログをだす
00045         midiumLevel = 2,
00046         /// たくさんのログをだす
00047         manyLevel = 3,
00048     };
00049     /**
00050      * コンストラクタ
00051      * @param fileName ログファイル名
00052      * @param logLevel 初期ログレベル
00053      */
00054     explicit Logger(const String& fileName, LogLevel logLevel = midiumLevel);
00055 
00056     /**
00057      * デストラクタ
00058      */
00059     virtual ~Logger();
00060 
00061     /**
00062      * ログ出力
00063      * @param logLevel ログレベル
00064      * @param message 出力メッセージ
00065      */
00066     virtual void output(LogLevel logLevel, String message);
00067 
00068     /**
00069      * ログ出力
00070      *
00071      * 普通のログレベルで出力されます。
00072      * @param message 出力メッセージ
00073      */
00074     virtual void output(String message){ output(midiumLevel, message); }
00075 
00076     /**
00077      * ログ出力
00078      * @param logLevel ログレベル
00079      * @param format フォーマット
00080      * @param ... 可変長引数
00081      */
00082     virtual void output(LogLevel logLevel, const char* format, ...);
00083 
00084     /**
00085      * ログ出力
00086      *
00087      * 普通のログレベルで出力されます。
00088      * @param format フォーマット
00089      * @param ... 可変長引数
00090      */
00091     virtual void output(const char* format, ...);
00092 
00093     /**
00094      * フラッシュ
00095      */
00096     virtual void flush();
00097 
00098     /**
00099      * ログレベルの設定
00100      * @param logLevel 設定するログレベル
00101      */
00102     virtual void setLogLevel(LogLevel logLevel){ logLevel_ = logLevel; }
00103 
00104     /**
00105      * ログレベルの取得
00106      * @return ログレベル
00107      */
00108     virtual LogLevel getLogLevel(){ return logLevel_; }
00109 
00110 private:
00111     // コピーコンストラクタの隠蔽
00112     Logger(const Logger& copy);
00113 
00114     // 代入コピーの隠蔽
00115     void operator =(const Logger& copy);
00116 
00117     // ライタ
00118     TextFileWriter* writer_;
00119     // ログレベル
00120     LogLevel logLevel_;
00121 };
00122 
00123 //------------------------------------------------------------------------------
00124 } // End of namespace Lamp
00125 #endif // End of LOGGER_H_
00126 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:32 2005 for Lamp by doxygen 1.3.2