コード例 #1
0
ファイル: logger.cpp プロジェクト: horizon3d/BSON
   void toFile(const int level,  const char* func,
               const char* file, const int line,
               const char* fmt, ...)
   {
      // get time now
      struct tm otm;
      struct timeval tv;
      time_t tt = time(NULL);
#ifdef _WIN32
      ::localtime_s(&otm, &tt);
#else
      otm = ::localtime_r(&tt);
#endif
      gettimeofday(&tv, NULL);
      // combine user log
      char userInfo[LOG_BUFFER_SIZE] = { 0 };
      va_list ap;
      va_start(ap, fmt);
      vsprintf_s(userInfo, LOG_BUFFER_SIZE, fmt, ap);
      va_end(ap);

      // combine content
      char buffer[LOG_BUFFER_SIZE] = { 0 };
      sprintf_s(buffer, LOG_BUFFER_SIZE, logFmt,
                otm.tm_year + 1900, otm.tm_mon + 1, otm.tm_mday,
                otm.tm_hour, otm.tm_min, otm.tm_sec, tv.tv_usec,
                toString(level), ossGetCurrentProcessId(), ossGetCurrentThreadId(),
                func, file, line, userInfo);

      // write to file
      LogWriter()->writeLog(level, buffer);
   }
コード例 #2
0
/**
 * DBInterface::init
 * @brief creates a LogWriter-object
 */
void DBInterface::init() {
    createIfNotCreatedDataBase();

    // create LogWriter-object
    log = LogWriter("DBInterface", PATH_OF_LOGFILE);

    log << SLevel(INFO) << "Initialized DBInterface with url : " << URL_OF_DATABASE << "." << endl;

}
コード例 #3
0
/**
 * ANNWrapper::ANNWrapper
 * @brief constructor of ANN-wrapper class, initializes LogWriter and ANN-objects
 *
 */
ANNWrapper::ANNWrapper(DBInterface *dbInterface_) {
    // create and initialize LogWriter-object
    log = LogWriter("ANNWrapper", PATH_OF_LOGFILE);
    log << SLevel(INFO) << "Initialized ANNWrapper" << endl;

    // initialize DBInterface
    dbi = dbInterface_;

    // initialize ANN-objects
    ANNTemperature.init("ANNTemperature",dbi,PATH_OF_NET_STRUCTURE_WITHOUT_LOSS,"",PATH_OF_NET_SOLVER);
    ANNAirPressure.init("ANNAirPressure",dbi,PATH_OF_NET_STRUCTURE_WITHOUT_LOSS,"",PATH_OF_NET_SOLVER);

}