view TaskManager/kernel/ppe/ExportTaskLog.cc @ 1531:4443d59a8210 draft

SDL.h in main.cc
author yuhi@cr.ie.u-ryukyu.ac.jp
date Fri, 07 Dec 2012 15:46:27 +0900
parents 9b0908cb7553
children
line wrap: on
line source

#include "ExportTaskLog.h"
const char* const ExportTaskLog::FILENAME="logfile.yml";

ExportTaskLog::ExportTaskLog(QueueInfo<TaskLog> *_tasklog)
{
    tasklog = _tasklog;

    open();
}

ExportTaskLog::~ExportTaskLog()
{
    close();
}

void
ExportTaskLog::open()
{
    if ((fp = fopen(FILENAME, "w")) == NULL) {
        printf("file open error!\n");
        exit(EXIT_FAILURE);
    };
}

void
ExportTaskLog::printOut()
{
    while(!tasklog->empty()){
        TaskLog *log = tasklog->poll();
        fprintf(fp, "--- \n");
        fprintf(fp, "task_id:      %d\n", log->mtask_id);
        fprintf(fp, "cmd:          %d\n", log->cmd);
        fprintf(fp, "create_time:  %llu\n", log->create_time);
        fprintf(fp, "execute_time: %llu\n", log->execute_time);
        fprintf(fp, "finish_time:  %llu\n", log->finish_time);
        fprintf(fp, "wait_for:\n");
        while(!log->wait_for_list.empty()){
            waitTask *task = log->wait_for_list.poll();
            fprintf(fp, "  - \n");
            fprintf(fp, "    task_id: %d\n", task->task_id);
            fprintf(fp, "    cmd:     %d\n", task->cmd);
        }
    }
}

void
ExportTaskLog::close()
{
    fclose(fp);
}