Esempio n. 1
0
/**
 * Create a new logfile.
 */
LogFile::LogFile(const char *inFilename)
{
    assert(inFilename);
    filename=inFilename;

    instream = NULL;
    outputter = NULL;
    file = NULL;

    try {
        /* Try to open the logfile */
        openLogfile();
        /* If it's opened succesfully, read the next (first) line */
        if(!nextLine()) {
            /* If nextLine didn't return a record, this entry is invalid. */
            throw LogfileError("Error trying to read an initial record.");
        } else {
            outputter = LineOutputter::forLine(line);
            closeLogfile();
        }
    } catch(LogfileError e) {
        if (file != NULL) {
            closeLogfile();
        }
        delete outputter;
        throw;
    }
}
Esempio n. 2
0
void LogFile::writeLine()
{
    if (instream == NULL) {
        openLogfile();
        nextLine();
    }

    outputter->writeLine(line);
}
Esempio n. 3
0
void cSmileLogger::setLogFile(const char *file, int _append, int _stde)
{
  if (file != NULL) {
    if (logfile) {
      free(logfile); logfile = NULL;
    }
    logfile = strdup(file);
    stde = _stde;
    openLogfile(_append);
  }
}
Esempio n. 4
0
DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
    : QDialog( parent )
    , ui( new Ui::DiagnosticsDialog )
{
    ui->setupUi( this );

    connect( ui->clipboardButton, SIGNAL( clicked() ), SLOT( copyToClipboard() ) );
    connect( ui->logfileButton, SIGNAL( clicked() ), SLOT( openLogfile() ) );
    connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( reject() ) );

    updateLogView();
}
Esempio n. 5
0
/**
 * Get the next line from a log file.
 * Return whether the seek actually occurred.
 */
bool LogFile::nextLine()
{
    bool rv=true;

    if(instream == NULL) {
        openLogfile();
        /* Recurse to skip a line */
        rv=nextLine();
        assert(rv);
    }

    std::getline(*instream, line);
    rv = !(instream->fail() || line.empty() || parseTimestamp() == -1);

    return rv;
}
Esempio n. 6
0
cSmileLogger::cSmileLogger(int loglevel_msg, int loglevel_wrn, int loglevel_err, int loglevel_dbg, const char *_logfile, int _append):
  logf(NULL),
  msg(NULL),
  silence(0),
  _enableLogPrint(1)
{
  if (_logfile != NULL) {
    logfile = strdup(_logfile);
    stde = 0;
    openLogfile(_append);
  }
  else { stde = 1; logfile = NULL; }

  ll_msg = loglevel_msg;
  ll_wrn = loglevel_wrn;
  ll_err = loglevel_err;
  ll_dbg = loglevel_dbg;
  smileMutexCreate(logmsgMtx);
}
Esempio n. 7
0
void appendToLogfile(const char* text)
{	
    word mjd; byte hour; byte min; byte sec; 
	word year; byte month; byte day; byte weekday;
    char str[20]; 

	//TAP_Print("Appending to log file...\r\n");
	openLogfile();

	if (logFD != NULL)
	{
		TAP_Hdd_Fseek(logFD, logByteCount, SEEK_SET);

        TAP_GetTime( &mjd, &hour, &min, &sec);
        TAP_ExtractMjd(mjd, &year, &month, &day, &weekday);
		sprintf(str,"%02d-%02d-%04d %02d:%02d:%02d - ", day, month, year, hour, min, sec);
		TAP_Hdd_Fwrite((void*)str, strlen(str), 1, logFD);
		TAP_Hdd_Fwrite((void*)text, strlen(text), 1, logFD);
		TAP_Hdd_Fwrite((void*)"\r\n", strlen("\r\n"), 1, logFD);
		logByteCount += strlen(str) + strlen(text) + strlen("\r\n");
		closeLogfile();
	}
	
}
Esempio n. 8
0
benchmarkResult benchmarkDetectionBase(const std::string &sAlgo, const std::string &sGrndtr, double threshold, bool writeLogFile, std::vector<FaceObject> &vAlgoGes, std::vector<FaceObject> &vGrndtrGes)
{
    QString qAlgo = sAlgo.c_str();
    QDir dirAlgo = qAlgo;
    std::string sFullpathAlgo, sFilename, sFullpathGrndtr;
    int tp = 0;
    benchmarkResult bRes;
    int iNumFacesGrndtr = 0;
    int iNumFacesAlgo = 0;
    int iSeqNo = 0;

    // Open logfile
    std::ofstream ofLog;
    if(writeLogFile)
        bRes.logFileName = openLogfile(ofLog, sAlgo, sGrndtr, threshold, "benchmarkDetection");

    // Iterate folders
    dirAlgo.setFilter(QDir::Files);
    QDirIterator itDirAlgo(dirAlgo);
    while(itDirAlgo.hasNext())
    {
        itDirAlgo.next();
        sFullpathAlgo = itDirAlgo.filePath().toUtf8().constData();
        sFilename = itDirAlgo.fileName().toUtf8().constData();
        sFullpathGrndtr = sGrndtr + "/" + sFilename;
        std::vector<FaceObject> vAlgo = readObjectFile(sFullpathAlgo);
        std::vector<FaceObject> vGrndtr = readObjectFile(sFullpathGrndtr);

        if(!QFile(sFullpathAlgo.c_str()).exists() || !QFile(sFullpathGrndtr.c_str()).exists())
            continue; // Go on if ground truth file and algo file exist.

        iNumFacesAlgo += vAlgo.size();
        iNumFacesGrndtr += vGrndtr.size();

        if(vAlgo.size() != 0 && vGrndtr.size() != 0)
        {
            // Compare FaceObjects of Algo and Grndtr
            double overlap[vAlgo.size()][vGrndtr.size()];
            for(size_t i=0; i<vAlgo.size(); i++)
            {
                for(size_t j=0; j<vGrndtr.size(); j++)
                {
                    overlap[i][j] = getOverlapRelToGrndtr(vAlgo[i], vGrndtr[j]);
                }
            }

            // Count number of TP
            for(size_t k=0; k<vAlgo.size(); k++)
            {
                double dHighestOverlap = -1.0;
                int iHighest = 0;
                int jHighest = 0;

                // get highest overlap value
                for(size_t i=0; i<vAlgo.size(); i++)
                {
                    for(size_t j=0; j<vGrndtr.size(); j++)
                    {
                        if(overlap[i][j] > dHighestOverlap)
                        {
                            dHighestOverlap = overlap[i][j];
                            iHighest = i;
                            jHighest = j;
                        }
                    }
                }

                // Check whether it is a TP
                if(dHighestOverlap >= threshold)
                    tp++;
                else
                    break;

                // Set row & col to -1 => Don't consider them in future
                for(size_t i=0; i<vAlgo.size(); i++)
                {
                    overlap[i][jHighest] = -1.0;
                }
                for(size_t j=0; j<vGrndtr.size(); j++)
                {
                    overlap[iHighest][j] = -1.0;
                }

                // Write seqNo to FO Grndtr and FO Algo
                vAlgo[iHighest].iSequentialNumber = iSeqNo;
                vGrndtr[jHighest].iSequentialNumber = iSeqNo;
                iSeqNo++;
            }
            // Add FOs to return-vectors
            for(size_t i=0; i<vAlgo.size(); i++)
                vAlgoGes.push_back(vAlgo[i]);
            for(size_t i=0; i<vGrndtr.size(); i++)
                vGrndtrGes.push_back(vGrndtr[i]);
        }

        int fp = vAlgo.size() - tp;
        int fn = vGrndtr.size() - tp;

        bRes.truePositives += tp;
        bRes.falsePositives += fp;
        bRes.falseNegatives += fn;

        // Write logfile entry
        if(writeLogFile)
            writeLogfileEntry(ofLog, sFilename, tp, fp, fn);

        tp = 0;
    }

    bRes.precision = precision(bRes.truePositives, bRes.falsePositives);
    bRes.recall = recall(bRes.truePositives, bRes.falseNegatives);

    // Write logfile summary
    if(writeLogFile)
        writeSummaryToLogFile(ofLog, bRes, iNumFacesGrndtr, iNumFacesAlgo);

    return bRes;
}