GitWatcherBot
1.0.0
A Telegram Bot that notifies you when a new change is made in your repositories (issues, pull requests, stars, forks, and watches)
Main Page
Namespaces
Namespace List
Namespace Members
All
Typedefs
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
f
g
i
l
o
p
r
s
t
u
w
~
Functions
a
b
f
g
i
l
o
r
t
u
~
Variables
a
c
d
f
i
l
o
p
s
t
u
w
Files
File List
File Members
All
Functions
Variables
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Macros
Logger.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <ctime>
4
#include <fstream>
5
#include <iostream>
6
#include <sstream>
7
#include "
db/models/Log.hpp
"
8
9
#define KNRM "\x1B[0m"
10
#define KRED "\x1B[31m"
11
#define KGRN "\x1B[32m"
12
#define KYEL "\x1B[33m"
13
#define KBLU "\x1B[34m"
14
#define KMAG "\x1B[35m"
15
#define KCYN "\x1B[36m"
16
#define KWHT "\x1B[37m"
17
18
#ifdef NDEBUG
19
static
constexpr
bool
kLogToConsole
=
false
;
20
#else
21
static
constexpr
bool
kLogToConsole
=
true
;
22
#endif
23
25
#define LOG(level, txt, longTxt, color) \
26
try \
27
{ \
28
std::ostringstream logoss{}, logosslng{}; \
29
logoss << txt; \
30
logosslng << longTxt; \
31
models::Log newLog(level, logoss.str(), logosslng.str()); \
32
Database::addLog(newLog); \
33
if constexpr (kLogToConsole) \
34
{ \
35
std::cout << color << newLog.toString() << std::endl; \
36
} \
37
} \
38
catch (const std::exception &e) \
39
{ \
40
std::cerr << "Failed to log ["
<< txt << "]: " << e.what(); \
41
}
42
43
44
#define LOGT(txt) LOG("trace"
, txt, "", KNRM)
45
#define LOGI(txt) LOG("info"
, txt, "", KGRN)
46
#define LOGW(txt) LOG("warn"
, txt, "", KYEL)
47
#define LOGE(txt) LOG("error"
, txt, "", KRED)
48
49
#define LOGT2(txt, longTxt) LOG("trace"
, txt, longTxt, KNRM)
50
#define LOGI2(txt, longTxt) LOG("info"
, txt, longTxt, KGRN)
51
#define LOGW2(txt, longTxt) LOG("warn"
, txt, longTxt, KYEL)
52
#define LOGE2(txt, longTxt) LOG("error"
, txt, longTxt, KRED)
Log.hpp
kLogToConsole
static constexpr bool kLogToConsole
Definition:
Logger.hpp:21
src
log
Logger.hpp
Generated on Sat Jun 22 2024 16:34:05 for GitWatcherBot by
1.9.1