-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cpp
More file actions
59 lines (47 loc) · 1.39 KB
/
Copy pathLogger.cpp
File metadata and controls
59 lines (47 loc) · 1.39 KB
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
//internal
#include <Logger.h>
#include <Postgre.h>
//system
#include <iostream>
//vcpkg
#include <pqxx/pqxx>
Logger::Logger(pqxx::connection* db)
{
DBCon = db;
}
void Logger::post(std::string programm_name, int appid, std::string message, std::string type)
{
try{
std::string request = "INSERT INTO logger (programm_name, game_appid, message,type,time) VALUES ($1,$2,$3,$4,NOW());";
pqxx::work txn(*DBCon);
txn.exec("SET application_name = 'Logger post'");
txn.exec_params(request,
programm_name,
appid,
message,
type
);
txn.commit();
}
catch (const std::exception& e) {
std::cerr << "Logger | post error: " << e.what() << std::endl;
}
}
void Logger::status(std::string programm_name, bool is_work)
{
try{
pqxx::work txn(*DBCon);
std::string request = "INSERT INTO status (programm_name,is_work,time) VALUES ($1,$2,NOW()) ON CONFLICT (programm_name) DO UPDATE SET programm_name = EXCLUDED.programm_name, is_work = EXCLUDED.is_work, time = NOW();";
txn.exec("SET application_name = 'Logger status'");
txn.exec_params(request,
programm_name,
is_work);
txn.commit();
}
catch (const std::exception& e) {
std::cerr << "Logger | status error: " << e.what() << std::endl;
}
}
Logger::~Logger()
{
}