35 #pragma warning(disable: 4996) 44 : m_pMutex( MutexPtr( new
Mutex() ))
47 std::string strFileName( pFileName );
49 if ( 0 < strTempPath.length() )
51 strFileName = strTempPath.append( strFileName );
54 m_File.open( strFileName.c_str(), std::fstream::app );
58 m_File.open( strFileName.c_str() );
80 if(
true ==
m_File.is_open() )
90 if(
true ==
m_File.is_open() )
93 time_t nTime = time( &nTime );
95 localtime_s( &timeInfo, &nTime );
97 asctime_s( strTime, 100, &timeInfo );
99 time_t nTime = time( NULL );
100 std::string strTime = asctime( localtime( &nTime ) );
103 m_File << strTime <<
": " << rStrMessage << std::endl;
113 if(tmpDir.size() == 0)
115 char *pPath = std::getenv(
"TMPDIR");
119 if(stat(pPath, &lStats) == 0)
125 if(tmpDir.size() == 0)
127 char *pPath = std::getenv(
"TEMP");
131 if(stat(pPath, &lStats) == 0)
137 if(tmpDir.size() == 0)
139 char *pPath = std::getenv(
"TMP");
143 if(stat(pPath, &lStats) == 0)
149 if(tmpDir.size() == 0)
151 std::string path =
"/tmp";
153 if(stat(path.c_str(), &lStats) == 0)
158 if(tmpDir.size() == 0)
160 std::string path =
"/var/tmp";
162 if(stat(path.c_str(), &lStats) == 0)
167 if(tmpDir.size() == 0)
169 std::string path =
"/usr/tmp";
171 if(stat(path.c_str(), &lStats) == 0)
176 if(tmpDir.size() == 0)
181 if( (*tmpDir.rbegin()) !=
'/' )
187 DWORD length = ::GetTempPathA( 0, NULL );
193 std::vector<TCHAR> tempPath( length );
195 length =
::GetTempPath( static_cast<DWORD>( tempPath.size() ), &tempPath[0] );
196 if( length == 0 || length > tempPath.size() )
201 return std::string( tempPath.begin(), tempPath.begin() +
static_cast<std::size_t
>(length) );
FileLogger(const char *pFileName, bool append=true)
std::string GetTempPath()
FileLogger & operator=(const FileLogger &)
void Log(const std::string &StrMessage)