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)
Loading...
Searching...
No Matches
Log.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
#include <string>
5
#include <cstring>
6
#include <ctime>
7
#include <sqlite_orm/sqlite_orm.h>
8
#include <tgbotxx/utils/DateTimeUtils.hpp>
9
#include <tgbotxx/utils/FileUtils.hpp>
10
#include <source_location>
11
12
namespace
models
{
13
14
struct
Log
{
15
std::int64_t
id
{};
16
std::string
severity
;
// TRACE, INFO, WARN, ERROR..
17
std::string
shortMessage
;
// Summary
18
std::string
longMessage
;
// Larger text, dump of json of update for example
19
std::time_t
timestamp
{};
20
// source location
21
std::string
filename
;
22
std::uint_least32_t
line
{};
23
std::uint_least32_t
column
{};
24
std::string
functionName
;
25
26
static
auto
table
() {
27
using namespace
sqlite_orm;
28
return
make_table(
"Logs"
,
29
make_column(
"id"
, &
Log::id
, primary_key().autoincrement()),
30
make_column(
"severity"
, &
Log::severity
),
31
make_column(
"shortMessage"
, &
Log::shortMessage
),
32
make_column(
"longMessage"
, &
Log::longMessage
, default_value(
""
)),
33
make_column(
"timestamp"
, &
Log::timestamp
),
34
make_column(
"filename"
, &
Log::filename
),
35
make_column(
"line"
, &
Log::line
),
36
make_column(
"column"
, &
Log::column
),
37
make_column(
"functionName"
, &
Log::functionName
)
38
);
39
}
40
41
Log
() =
default
;
42
43
Log
(
const
std::string &sev,
const
std::string &shortMsg,
const
std::string &longMsg =
""
,
const
std::source_location& here = std::source_location::current()) {
44
severity
= sev;
45
shortMessage
= shortMsg;
46
longMessage
= longMsg;
47
timestamp
= std::time(
nullptr
);
48
filename
= here.file_name();
49
line
= here.line();
50
column
= here.column();
51
functionName
= here.function_name();
52
}
53
54
55
std::string
toString
() const noexcept {
56
std::ostringstream oss{};
57
oss << fs::path(
filename
).filename().string() <<
':'
<<
line
<<
':'
<<
column
<<
" ["
<<
functionName
<<
"] ["
<< tgbotxx::DateTimeUtils::toString(
timestamp
) <<
"] ["
<<
severity
<<
"]: "
<<
shortMessage
;
58
return
oss.str();
59
}
60
};
61
}
models
Definition
Log.hpp:12
models::Log
Definition
Log.hpp:14
models::Log::shortMessage
std::string shortMessage
Definition
Log.hpp:17
models::Log::filename
std::string filename
Definition
Log.hpp:21
models::Log::timestamp
std::time_t timestamp
Definition
Log.hpp:19
models::Log::longMessage
std::string longMessage
Definition
Log.hpp:18
models::Log::id
std::int64_t id
Definition
Log.hpp:15
models::Log::line
std::uint_least32_t line
Definition
Log.hpp:22
models::Log::severity
std::string severity
Definition
Log.hpp:16
models::Log::Log
Log(const std::string &sev, const std::string &shortMsg, const std::string &longMsg="", const std::source_location &here=std::source_location::current())
Definition
Log.hpp:43
models::Log::table
static auto table()
Definition
Log.hpp:26
models::Log::column
std::uint_least32_t column
Definition
Log.hpp:23
models::Log::toString
std::string toString() const noexcept
Definition
Log.hpp:55
models::Log::Log
Log()=default
models::Log::functionName
std::string functionName
Definition
Log.hpp:24
src
db
models
Log.hpp
Generated on Sat Oct 25 2025 10:12:18 for GitWatcherBot by
1.9.8