/[PAMELA software]/yoda/techmodel/techmodelreader.cpp
ViewVC logotype

Diff of /yoda/techmodel/techmodelreader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by kusanagi, Mon Jul 26 23:09:45 2004 UTC revision 1.6 by kusanagi, Thu Aug 26 08:21:31 2004 UTC
# Line 49  int main(int argc, char* argv[]) { Line 49  int main(int argc, char* argv[]) {
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     log4cpp::Appender* appender;     tmpnam(nomeFileLog);
54     log4cpp::Category& cat = log4cpp::Category::getRoot();  
55     DIR *dirp;      DIR *dirp;
    //std::string pathDir((char*)getenv("YODA_LOGS"));  
56     std::string pathDir((char*)getenv("YODA_DATA"));     std::string pathDir((char*)getenv("YODA_DATA"));
57             std::string pathLog = nomeFileLog;
58     std::string pathLog = pathDir + "/" + nomeFileLog;     log4cpp::Category& root = log4cpp::Category::getRoot();
59     appender = new log4cpp::FileAppender("default", pathLog.c_str(), false);     try{
60     log4cpp::PatternLayout * pl = new log4cpp::PatternLayout();      std::string initFileName = pathDir + "/log4cpp.conf";
61     pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m");      log4cpp::PropertyConfigurator::configure(initFileName);
62     appender->setLayout(pl);     } catch (log4cpp::ConfigureFailure& f) {
63     cat.setAppender(appender);      std::cerr << "Could not load log configuration from file: " << f.what() << std::endl
64     cat.setPriority(log4cpp::Priority::DEBUG);                << "Using default setup (all msgs to stdout)" << std::endl;
65        log4cpp::Appender* appender;
66        appender = new log4cpp::FileAppender("default", pathLog.c_str(), false);
67        // set a nice layout
68        log4cpp::PatternLayout * pl = new log4cpp::PatternLayout();
69        pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m");
70        appender->setLayout(pl);
71        //log4cpp::Category& cat  = log4cpp::Category::getInstance("cat");
72        // remove default appender
73        cat.removeAllAppenders();
74        // use this appender for all categories
75        cat.addAppender(appender);
76        
77        // log messages from all levels.
78        //cat.setPriority(log4cpp::Priority::DEBUG);
79        //cat.setPriority(log4cpp::Priority::WARN);
80        cat.setPriority(log4cpp::Priority::INFO);
81       }
82    
83      time_t rawtime;      time_t rawtime;
84      struct tm * timeinfo;      struct tm * timeinfo;
85    
86      time ( &rawtime );      time ( &rawtime );
87      timeinfo = localtime ( &rawtime );      timeinfo = localtime ( &rawtime );
88  //--------------------------------------------------    //--------------------------------------------------  
89        cat.log(log4cpp::Priority::INFO,"Importance depends on context");
90      cat << log4cpp::Priority::INFO      cat << log4cpp::Priority::INFO
91      << "<-------------------------------START UNPACKING------------------------------->\n"      << "<-------------------------------START UNPACKING------------------------------->\n"
92      << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]      << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]
# Line 90  int main(int argc, char* argv[]) { Line 108  int main(int argc, char* argv[]) {
108          << "\n " << log4cpp::CategoryStream::ENDLINE;          << "\n " << log4cpp::CategoryStream::ENDLINE;
109      log4cpp::Category::shutdown();      log4cpp::Category::shutdown();
110    std::string command;    std::string command;
111    command = "mv " + pathLog + "  " + pathDir + "/" + Run.GetRun() + "/.";    //command = "mv " + pathLog + "  " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
112      command = "mv " + pathLog + "  " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
113    cat.info(command);    cat.info(command);
114    system(command.c_str());    system(command.c_str());
115  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23