Skip to content
Snippets Groups Projects
Commit e6b11625 authored by jgatt's avatar jgatt
Browse files

log format change now job_id and username are splitted

parent 9530662f
Branches
Tags
1 merge request!12Merge Request multibehavior
#include "broker/log_user_stat.hpp"
#include "../pempek_assert.hpp"
BehaviorStat::BehaviorStat(Job* job,
std::string behavior_name,double time_delayed){
this->job = job;
this->behavior_name = behavior_name;
this->time_delayed = time_delayed;
}
std::vector<std::string> BehaviorStat::split_id(){
std::string job_id = job->id;
std::vector<std::string> splitting;
splitting.push_back("");
for( std::string::size_type i =0 ; i < job_id.length();i++){
if(job_id[i]=='!'){
splitting.push_back("");
}
else
{
splitting.back() += job_id[i];
}
}
return splitting;
}
boost::basic_format<char> BehaviorStat::format()
{
return boost::format("%1%,%2%,%3%,%4%\n") % job->id
% job->submission_time % behavior_name % time_delayed;
std::vector<std::string> splitting = split_id();
PPK_ASSERT_ERROR(splitting.size()<2,
"Error logging the job behavior the job_id should be of the format"
" user_id!job_id");
return boost::format("%1%,%2%,%3%,%4%,%5%\n") % splitting[0] %
splitting[1] % job->submission_time % behavior_name % time_delayed;
}
LoggerUserStat::LoggerUserStat(std::string log_folder)
......@@ -32,7 +53,7 @@ void LoggerUserStat::log_stat(){
std::ofstream file;
if (put_header){
file.open(log_folder + "/user_stats_behaviors.csv");
file << "job_id,submission_time, behavior_name,time_delayed\n";
file << "user,job_id,submission_time, behavior_name,time_delayed\n";
put_header=false;
}
else{
......
......@@ -14,6 +14,7 @@ struct BehaviorStat {
double submission_time;
BehaviorStat( Job* job,
std::string behavior_name,double time_delayed);
std::vector<std::string> split_id();
boost::basic_format<char> format();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment