Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timestamp in json output #26

Open
antreos opened this issue Dec 30, 2019 · 1 comment
Open

timestamp in json output #26

antreos opened this issue Dec 30, 2019 · 1 comment

Comments

@antreos
Copy link

antreos commented Dec 30, 2019

hi,

any chance to get a timestamp in the json log output?

@askat86
Copy link

askat86 commented Apr 4, 2020

i did this for my own tracking purpose and here is the code:

#include <ctime>

std::time_t result = std::time(nullptr);
char * time = std::asctime(std::localtime(&result));
time[strlen(time)-1] = '\0'; // get rid of new line added in asctime
if (programOptions.output_type == OutputType::text) {
    std::cout << "TIME=" << time << std::endl;
} else if (programOptions.output_type == OutputType::json) {
    std::cout << "\"time\":\"" << time << "\",";
}

feel free to use it, if it is good enough for you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants