Ignore:
Timestamp:
Jul 12, 2007, 2:57:04 AM (17 years ago)
Author:
dai_9181
Message:

コード全体のリファクタリングを実施

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jenga/include/common/logger.h

    r166 r205  
    1313
    1414#include <jenga/include/common/Environment.h>
     15#include <jenga/include/common/BoostXmlSupport.h>
    1516
    1617#define STDX_DSTREAM_BUFFERING
     
    2324
    2425
     26class LoggerSetting : public BoostXmlSupport<LoggerSetting>
     27{
     28public:
     29    int stopStep;
     30
     31    LoggerSetting()
     32        : stopStep( -1 )
     33    {
     34    }
     35
     36    // XMLシリアライズ用
     37private:
     38    virtual const char *RootTagName() const
     39    {
     40        return "loggerSetting";
     41    }
     42    friend class boost::serialization::access;
     43    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     44    {
     45        ar & BOOST_SERIALIZATION_NVP( stopStep );
     46    }
     47};
     48
     49
    2550// VC++ で STLport だと using std::char_traits; みたいなのが必要かも
    2651template <typename Ch_T, typename Tr_T = std::char_traits<Ch_T> >
     
    2954protected:
    3055    std::string saveFilePath;
     56    int count;
     57    LoggerSetting setting;
    3158
    3259public:
    33     basic_dbg_streambuf( const std::string &saveFilePath )
     60    basic_dbg_streambuf( const std::string &saveFilePath, bool isOptionEnabled )
    3461        : saveFilePath( saveFilePath )
     62        , count( 0 )
    3563    {
    3664#ifndef STDX_DSTREAM_BUFFERING
    3765        setbuf(0,0);
    3866#endif
     67
     68        if( isOptionEnabled )
     69        {
     70            // 設定ファイルを読み込む
     71            char temporary[MAX_PATH];
     72            char temp2[MAX_PATH];
     73            char temp3[MAX_PATH];
     74            _splitpath(saveFilePath.c_str(),temporary,temp2,temp3,NULL);
     75            setting.Read( (string)temporary + temp2 + temp3 + ".setting.xml", false );
     76        }
    3977    }
    4078
     
    5997{
    6098    ofstream ofs( ( saveFilePath ).c_str(), ios_base::app );
    61     ofs << str ;
     99    ofs << "[" << (count++) << "] " << str ;
    62100    ofs.close();
     101
     102    if( (count-1) == setting.stopStep )
     103    {
     104        DebugBreak();
     105    }
    63106}
    64107
     
    67110{
    68111public:
    69     basic_dbg_ostream( const string &saveFilePath )
    70         : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath))
     112    basic_dbg_ostream( const string &saveFilePath, bool isOptionEnabled )
     113        : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath,isOptionEnabled))
    71114    {
    72115        ofstream ofs( ( saveFilePath ).c_str(), ios_base::trunc );
     
    87130
    88131}}
     132
     133BOOST_CLASS_IMPLEMENTATION(Jenga::Common::LoggerSetting, boost::serialization::object_serializable);
Note: See TracChangeset for help on using the changeset viewer.