Adding dedicated time format for Elasticsearch.

parent fa7a3f29
......@@ -315,6 +315,8 @@ int main(int argc, char **argv)
Arc::Time::SetFormat(Arc::UserTime);
} else if(strcmp(log_time_format,"USEREXT") == 0) {
Arc::Time::SetFormat(Arc::UserExtTime);
} else if(strcmp(log_time_format,"ELASTIC") == 0) {
Arc::Time::SetFormat(Arc::ElasticTime);
} else if(strcmp(log_time_format,"MDS") == 0) {
Arc::Time::SetFormat(Arc::MDSTime);
} else if(strcmp(log_time_format,"ASC") == 0) {
......
......@@ -401,6 +401,26 @@ namespace Arc {
return ss.str();
}
case ElasticTime:
{
tm tmtime;
localtime_r(&gtime, &tmtime);
std::stringstream ss;
ss << std::setfill('0');
ss << std::setw(4) << tmtime.tm_year + 1900 << '-'
<< std::setw(2) << tmtime.tm_mon + 1 << '-'
<< std::setw(2) << tmtime.tm_mday << ' '
<< std::setw(2) << tmtime.tm_hour << ':'
<< std::setw(2) << tmtime.tm_min << ':'
<< std::setw(2) << tmtime.tm_sec << '.'
<< std::setw(3) << gnano/1000000;
return ss.str();
}
case MDSTime:
{
tm tmtime;
......
......@@ -24,7 +24,8 @@ namespace Arc {
UTCTime, ///< YYYY-MM-DDTHH:MM:SSZ
RFC1123Time, ///< Day, DD Mon YYYY HH:MM:SS GMT
EpochTime, ///< 1234567890
UserExtTime ///< YYYY-MM-DD HH:MM:SS.mmmmmm
UserExtTime, ///< YYYY-MM-DD HH:MM:SS.mmmmmm (microseconds resolution)
ElasticTime, ///< YYYY-MM-DD HH:MM:SS.mmm (milliseconds resolution, suitable for Elasticsearch)
};
/// Base to use when constructing a new Period.
......
......@@ -128,6 +128,8 @@ int main(int argc,char** argv) {
Arc::Time::SetFormat(Arc::UserTime);
} else if(strcmp(log_time_format,"USEREXT") == 0) {
Arc::Time::SetFormat(Arc::UserExtTime);
} else if(strcmp(log_time_format,"ELASTIC") == 0) {
Arc::Time::SetFormat(Arc::ElasticTime);
} else if(strcmp(log_time_format,"MDS") == 0) {
Arc::Time::SetFormat(Arc::MDSTime);
} else if(strcmp(log_time_format,"ASC") == 0) {
......@@ -208,6 +210,8 @@ int main(int argc,char** argv) {
Arc::Time::SetFormat(Arc::UserTime);
} else if(strcmp(log_time_format,"USEREXT") == 0) {
Arc::Time::SetFormat(Arc::UserExtTime);
} else if(strcmp(log_time_format,"ELASTIC") == 0) {
Arc::Time::SetFormat(Arc::ElasticTime);
} else if(strcmp(log_time_format,"MDS") == 0) {
Arc::Time::SetFormat(Arc::MDSTime);
} else if(strcmp(log_time_format,"ASC") == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment