]> git.stg.codes - stg.git/blob - projects/traffcounter/logger.cpp
Merge branch 'naffanya-dev'
[stg.git] / projects / traffcounter / logger.cpp
1 #include <string>
2 #include <sstream>
3
4 #include <ctime>
5
6 #include "logger.h"
7
8 using namespace std;
9
10 STGLogger::~STGLogger()
11 {
12 }
13
14 ostream & STGLogger::operator <<(const string & val)
15 {
16     LogDate();
17     out << " " << val;
18     return out;
19 }
20
21 void STGLogger::LogDate()
22 {
23     time_t t(time(NULL));
24     struct tm * tt = localtime(&t);
25     out << "[" << tt->tm_year + 1900 << "-";
26     out << (tt->tm_mon + 1 < 10 ? "0" : "") << tt->tm_mon + 1 << "-";
27     out << (tt->tm_mday < 10 ? "0" : "") << tt->tm_mday << " ";
28     out << (tt->tm_hour < 10 ? "0" : "") << tt->tm_hour << ":";
29     out << (tt->tm_min < 10 ? "0" : "") << tt->tm_min << ":";
30     out << (tt->tm_sec < 10 ? "0" : "") << tt->tm_sec << "]";
31 }