Ignore:
Timestamp:
Jun 17, 2007, 9:55:40 PM (17 years ago)
Author:
dai_9181
Message:

Directoryクラスを追加

File:
1 edited

Legend:

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

    r164 r166  
    2727class basic_dbg_streambuf: public std::basic_stringbuf<Ch_T, Tr_T>
    2828{
     29protected:
     30    std::string saveFilePath;
     31
    2932public:
    30   basic_dbg_streambuf()
    31     {
     33    basic_dbg_streambuf( const std::string &saveFilePath )
     34        : saveFilePath( saveFilePath )
     35    {
    3236#ifndef STDX_DSTREAM_BUFFERING
    33       setbuf(0,0);
     37        setbuf(0,0);
    3438#endif
    35     }
     39    }
    3640
    37   virtual ~basic_dbg_streambuf()
    38     {
    39       sync();
    40     }
     41    virtual ~basic_dbg_streambuf()
     42    {
     43        sync();
     44    }
    4145
    4246protected:
    43   int sync(void)
    44     {
    45       dbg_out(str().c_str());
    46       pbump(static_cast<int>(pbase() - pptr()));
    47       return 0;
    48     }
     47    int sync(void)
     48    {
     49        dbg_out(str().c_str());
     50        pbump(static_cast<int>(pbase() - pptr()));
     51        return 0;
     52    }
    4953
    50   void dbg_out(const Ch_T*);
     54    void dbg_out(const Ch_T*);
    5155};
    5256
     
    5458inline void basic_dbg_streambuf<char>::dbg_out(const char *str)
    5559{
    56     ofstream ofs( ( Environment::GetAppDir() + "\\logger.log" ).c_str(), ios_base::app );
     60    ofstream ofs( ( saveFilePath ).c_str(), ios_base::app );
    5761    ofs << str ;
    5862    ofs.close();
     
    6367{
    6468public:
    65 basic_dbg_ostream() : std::basic_ostream<Ch_T, Tr_T>(new \
    66     basic_dbg_streambuf<Ch_T, Tr_T>())
    67     {
    68         ofstream ofs( ( Environment::GetAppDir() + "\\logger.log" ).c_str(), ios_base::trunc );
     69    basic_dbg_ostream( const string &saveFilePath )
     70        : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath))
     71    {
     72        ofstream ofs( ( saveFilePath ).c_str(), ios_base::trunc );
    6973        ofs.close();
    70     }
     74    }
    7175
    72   virtual ~basic_dbg_ostream()
    73     {
    74       // flush(); // 不要らしい.http://www.tietew.jp/cppll/archive/607
    75       delete rdbuf();
    76     }
     76
     77    virtual ~basic_dbg_ostream()
     78    {
     79        // flush(); // 不要らしい.http://www.tietew.jp/cppll/archive/607
     80        delete rdbuf();
     81    }
    7782};
    7883
    7984
    80 static basic_dbg_ostream<_TCHAR> logger;
     85typedef basic_dbg_ostream<_TCHAR>  Logger;
    8186
    8287
Note: See TracChangeset for help on using the changeset viewer.