-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logs.cpp
41 lines (34 loc) · 1.08 KB
/
Logs.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
#include <vcl.h>
#pragma hdrstop
#include "Logs.h"
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
using namespace std;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
string returnCurrTime() {
time_t now = time(0);
tm* tmNow = localtime(&now);
char tempLine[100];
strftime(tempLine, 50, "%H:%M:%S %d.%m.%Y", tmNow);
return (tempLine);
}
void createLogFile() {
ofstream logFile(mainFolder + "\\" + logFilePath);
logFile << "ReaderHelper v." + appVersion << endl;
logFile << "Last Launched: [" + returnCurrTime() + "]" << endl;
logFile.close();
}
void addLogLine(string exception) {
ofstream logFile;
logFile.open(mainFolder + "\\" + logFilePath, ios_base::app);
logFile << "[" << returnCurrTime() << "] " << exception << ";" << endl;
logFile.close();
}