-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.hpp
More file actions
37 lines (33 loc) · 921 Bytes
/
Copy pathlogging.hpp
File metadata and controls
37 lines (33 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <ctime>
#include <iostream>
#include <fstream>
#include <direct.h>
#ifndef __EASYLOG_PIPI_0813
#define __EASYLOG_PIPI_0813
namespace EasyLog
{
static char* log_path = nullptr;
static std::string* environ_name = nullptr;
static void Write(std::string log) {
//if (!log_path) return;
try
{
std::ostream& ofs = std::cout;
time_t t = time(0);
char tmp[64];
strftime(tmp, sizeof(tmp), "[%Y-%m-%d %X]", localtime(&t));
//ofs.open(log_path, std::ofstream::app);
ofs << tmp << ' ';
if (environ_name != nullptr) {
ofs << '[' << *environ_name << "] ";
}
ofs.write(log.c_str(), log.size());
ofs << std::endl;
//ofs.close();
}
catch(...)
{
}
}
};
#endif