#include "log4cpp/Category.hh" #include "log4cpp/PropertyConfigurator.hh" #include "log4cpp/RollingFileAppender.hh" #include "log4cpp/PatternLayout.hh" #include "TROOT.h" #include "TechmodelPamelaRun.h" #include "EventReader.h" #include #include #include #include extern "C" { //#include "DirectoryStructure.h" #include } using namespace pamela; using namespace pamela::techmodel; static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.TechmodelReader"); int main(int argc, char* argv[]) { // Check file name if (argc != 2){ cat.info("You have forgotten the file name"); exit(1); } std::ifstream from (argv[1]); if (!from) cat.info("The file does not exist"); /*try { log4cpp::PropertyConfigurator::configure("/home/kusanagi/yoda/techmodel/YodaLog.conf"); } catch (log4cpp::ConfigureFailure& f) { std::cerr << "Logging Configure Problem " << f.what() << std::endl; }*/ //-------------------------------------------------- //This is the configuration for the Yoda Logger //The parameters in the RollingFileAppender means // default ------------>the selected category // YodaLog.txt ------------>the LogFile name // 1000 ------------>The max size (in Kb) of the LogFile // 5 ------------>How many times the file will be backup std::string nomeFileLog = "YodaLog.txt"; log4cpp::Appender* appender; log4cpp::Category& cat = log4cpp::Category::getRoot(); DIR *dirp; //std::string pathDir((char*)getenv("YODA_LOGS")); std::string pathDir((char*)getenv("YODA_DATA")); std::string pathLog = pathDir + "/" + nomeFileLog; appender = new log4cpp::FileAppender("default", pathLog.c_str(), false); log4cpp::PatternLayout * pl = new log4cpp::PatternLayout(); pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m"); appender->setLayout(pl); cat.setAppender(appender); cat.setPriority(log4cpp::Priority::DEBUG); time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); //-------------------------------------------------- cat << log4cpp::Priority::INFO << "<-------------------------------START UNPACKING------------------------------->\n" << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1] << "\n \n" << log4cpp::CategoryStream::ENDLINE; gROOT->SetBatch(kTRUE); EventReader Reader; int num = 0; TechmodelPamelaRun Run(argv[1]); Reader.Init(&Run); cat << log4cpp::Priority::INFO << "Init successul ok" << asctime (timeinfo) << log4cpp::CategoryStream::ENDLINE; Reader.RunEvent(num); //TBD --- eliminate the runNumber Reader.Finish(); Run.WriteFiles(); cat << log4cpp::Priority::INFO << "<-------------------------------END UNPACKING------------------------------->" << "\n " << log4cpp::CategoryStream::ENDLINE; log4cpp::Category::shutdown(); std::string command; command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/."; cat.info(command); system(command.c_str()); }