-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLogger.cpp
66 lines (56 loc) · 1.57 KB
/
Logger.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
This file is part of swan2 project.
Copyright (C) 2013 by Nick Sharmanzhinov
except134@gmail.com
*/
#include "PCH.h"
using namespace swan2;
using namespace swan2::lib;
using namespace swan2::lib::core;
std::string DEFAULT_LOG_FILE="AN2.txt";
Logger::Logger()
{
#ifdef LOGGING
VersionInfo ver(GetModuleHandle(NULL));
char ret[MAX_BUFFER_LENGTH];
ver.AsString(ret);
std::string v=ver.GetProductName()+std::string(", version ")+std::string(ret);
Start(DEFAULT_LOG_FILE,v);
#endif
}
Logger::~Logger()
{
#ifdef LOGGING
this->WriteEndHeader();
this->Close();
#endif
}
bool Logger::WriteStartHeader(const std::string& prjStr)
{
#ifdef LOGGING
DateTime dt;
Write("============================================================================\n");
Write(" %s\n",prjStr.data());
Write(" Log created on %s, at %s\n",dt.GetCurDate().c_str(),dt.GetCurTime().c_str());
Write("============================================================================\n\n");
#endif
return true;
}
bool Logger::WriteEndHeader()
{
#ifdef LOGGING
DateTime dt;
Write("\n\n============================================================================\n");
Write(" Log closed on %s, at %s\n",dt.GetCurDate().c_str(),dt.GetCurTime().c_str());
Write("============================================================================\n\n");
#endif
return true;
}
bool Logger::Start(const std::string& strFile,const std::string& prjStr)
{
#ifdef LOGGING
this->InitFile(strFile);
this->WriteStartHeader(prjStr);
#endif
return true;
}