Fix log file name format mm-dd

testing
marcelb 2 years ago
parent d12ef77ba5
commit 993869bbc3
  1. 1
      example/2023-05-21.log
  2. 1
      example/2023-5-21.log
  3. 6
      src/log.cpp
  4. 5
      test/test.cpp
  5. BIN
      test/test.o

@ -0,0 +1 @@
23:08:58 [EVENT] Start loging

@ -1 +1,2 @@
11:00:58 [EVENT] Start loging
13:02:17 [EVENT] Start loging

@ -82,7 +82,11 @@ void log::setPath() {
if (dir[dir.length()-1] != '/') {
dir.push_back('/');
}
path = dir + to_string(moment->tm_year+1900) + '-' + to_string(moment->tm_mon+1) + '-' + to_string(moment->tm_mday) + ".log";
stringstream mon, _day;
mon << setw(2) << setfill('0') << moment->tm_mon+1;
_day << setw(2) << setfill('0') << moment->tm_mday;
path = dir + to_string(moment->tm_year+1900) + '-' + mon.str() + '-' + _day.str() + ".log";
}
void log::setPrefix(string &logline) {

@ -3,12 +3,13 @@
#include "../lib/log.hpp"
using namespace std;
log mylog("../example", false);
int main() {
log mylog("../example", false);
// log mylog("../example", false);
mylog.put("[EVENT] Start loging");
return 0;
}
}

Binary file not shown.
Loading…
Cancel
Save