1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| bool WriteLog(std::string strdata, std::string strpath)
{
char* tmpdate = new char[256];
char buffer [80];
struct tm *gm;
struct tm *lm;
time_t maintenant;
time(&maintenant);
gm=gmtime(&maintenant);
//lm=localtime(&maintenant);
gm->tm_hour=gm->tm_hour;
sprintf(tmpdate,"%02d/%02d/%02d %02d:%02d:%02d GMT : ",
gm->tm_mday, gm->tm_mon + 1, gm->tm_year % 100,
gm->tm_hour, gm->tm_min, gm->tm_sec);
std::string strdate = std::string(tmpdate);
std::fstream fileLOG(strpath.c_str(),std::ios::app);
fileLOG.exceptions ( std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit );
try
{
fileLOG.write((strdate+strdata).c_str(),(strdate+strdata).length());
fileLOG.close();
return true;
}
catch(std::fstream::failure e)
{
std::cout <<"exception de fichier non geree"<<std::endl;
return false;
}
} |
Qu'est ce que tu penses de ma fonction log ?
Enfin je trouve quand même bizarre que ça plante alors qu'elle est même pas encore appelée !! C'est sa definition qui me fait tout planter ...
edit : Mon pb se passe quand j'appele cette fonction de ma fonction log :
std::fstream fileLOG(strpath.c_str(),std::ios::app);
Partager