49 |
// YodaLog.txt ------------>the LogFile name |
// YodaLog.txt ------------>the LogFile name |
50 |
// 1000 ------------>The max size (in Kb) of the LogFile |
// 1000 ------------>The max size (in Kb) of the LogFile |
51 |
// 5 ------------>How many times the file will be backup |
// 5 ------------>How many times the file will be backup |
52 |
std::string nomeFileLog = "YodaLog.txt"; |
char nomeFileLog[L_tmpnam]; |
53 |
|
tmpnam(nomeFileLog); |
54 |
|
//std::string nomeFileLog = "YodaLog.txt"; |
55 |
log4cpp::Appender* appender; |
log4cpp::Appender* appender; |
56 |
log4cpp::Category& cat = log4cpp::Category::getRoot(); |
log4cpp::Category& cat = log4cpp::Category::getRoot(); |
57 |
DIR *dirp; |
DIR *dirp; |
|
//std::string pathDir((char*)getenv("YODA_LOGS")); |
|
58 |
std::string pathDir((char*)getenv("YODA_DATA")); |
std::string pathDir((char*)getenv("YODA_DATA")); |
59 |
|
|
60 |
std::string pathLog = pathDir + "/" + nomeFileLog; |
//std::string pathLog = pathDir + "/" + nomeFileLog; |
61 |
|
std::string pathLog = nomeFileLog; |
62 |
appender = new log4cpp::FileAppender("default", pathLog.c_str(), false); |
appender = new log4cpp::FileAppender("default", pathLog.c_str(), false); |
63 |
log4cpp::PatternLayout * pl = new log4cpp::PatternLayout(); |
log4cpp::PatternLayout * pl = new log4cpp::PatternLayout(); |
64 |
pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m"); |
pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m"); |
65 |
appender->setLayout(pl); |
appender->setLayout(pl); |
66 |
cat.setAppender(appender); |
cat.setAppender(appender); |
67 |
cat.setPriority(log4cpp::Priority::DEBUG); |
//cat.setPriority(log4cpp::Priority::DEBUG); |
68 |
|
//cat.setPriority(log4cpp::Priority::WARN); |
69 |
|
cat.setPriority(log4cpp::Priority::INFO); |
70 |
time_t rawtime; |
time_t rawtime; |
71 |
struct tm * timeinfo; |
struct tm * timeinfo; |
72 |
|
|
94 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
95 |
log4cpp::Category::shutdown(); |
log4cpp::Category::shutdown(); |
96 |
std::string command; |
std::string command; |
97 |
command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/."; |
//command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt"; |
98 |
|
command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt"; |
99 |
cat.info(command); |
cat.info(command); |
100 |
system(command.c_str()); |
system(command.c_str()); |
101 |
} |
} |