view TaskManager/kernel/ppe/ExportTaskLog.cc @ 1474:b158873485f6 draft

fix simple task
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 16 Jul 2012 11:01:40 +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);
}