Skip to content

Instantly share code, notes, and snippets.

@indraniel
Created December 12, 2016 02:46
Show Gist options
  • Select an option

  • Save indraniel/afdadda18732943a5cecfc1ca8fa283e to your computer and use it in GitHub Desktop.

Select an option

Save indraniel/afdadda18732943a5cecfc1ca8fa283e to your computer and use it in GitHub Desktop.
Example Simple C++ logging (w/o C++11 or later)
#include <iostream>
#include <ctime>
void logMsg( const std::string& msg ) {
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,80,"%Y-%m-%d %H:%M:%S",timeinfo);
std::string str(buffer);
std::cout << "[" << str << "]" << " ---> " << msg << std::endl;
}
int main() {
logMsg("Here I am!");
logMsg("Bye Bye");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment