Bonjour à tous voici un bout de code
Mon problème c'est que dans mon loggeur il me dit toujours "Impossible de terminer le rendu de scène", alors qu'après de multiple test cette méthode semblent fonctionner correctement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 void CSLEngine::EndScene() { try { m_pVideoMode->Display(); throw CException(__LINE__, "Impossible de terminer le rendu de scène"); } catch(const CException &e) { CLogger::LogToFile(CLogger::ITError, e.what(), "CSLEngine"); } }
Y'a-t-il une erreur dans cette méthode?
Voici le code de la classe loggeur si besoin est
CLogger.h
CLogger.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #ifndef __CLogger_h__ #define __CLogger_h__ #include <iostream> #include <fstream> #include <string> namespace SLE { class CLogger { public: enum InfoType { ITInfo, ITWarning, ITError }; static void SetFileName(const std::string strFileName = "LogFile.txt"); static void LogToFile(InfoType ITType, const std::string &strMessage, const std::string &strEntry); private: CLogger(); virtual ~CLogger(); //Flux du fichier log static std::string m_strFileName; }; } #endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
35
36
37
38
39
40
41 #include "CLogger.h" using namespace SLE; std::string CLogger::m_strFileName; CLogger::CLogger() {} CLogger::~CLogger() {} void CLogger::SetFileName(const std::string strFileName) { m_strFileName = strFileName; //Vide le fichier de log existant std::ofstream ofsLogFile(m_strFileName.c_str(),std::ios::trunc); ofsLogFile.close(); } void CLogger::LogToFile(CLogger::InfoType ITType, const std::string &strMessage, const std::string &strEntry) { std::ofstream ofsLogFile(m_strFileName.c_str(),std::ios::app); std::string strInfo; switch (ITType) { case ITInfo: strInfo = "Info"; break; case ITWarning: strInfo = "Warning"; break; case ITError: strInfo = "Error"; break; } ofsLogFile << strInfo << " -- " << strMessage << " -- " << strEntry << std::endl; ofsLogFile.close(); }
Partager