ed
src
logging.cpp
Go to the documentation of this file.
1
#include "
ed/logging.h
"
2
3
#include <
iostream
>
4
#include <pthread.h>
5
6
namespace
7
{
8
std::string
prefix()
9
{
10
std::string
ps =
"[ED] "
;
11
12
// Add thread name
13
char
name[1000];
14
size_t
name_size = 1000;
15
if
(pthread_getname_np(pthread_self(), name, name_size) == 0)
16
ps +=
"("
+
std::string
(name) +
") "
;
17
18
return
ps;
19
}
20
}
21
22
namespace
ed
23
{
24
25
namespace
log
26
{
27
28
// ----------------------------------------------------------------------------------------------------
29
30
std::ostream
&
info
()
31
{
32
std::cout
<<
"\e[1;37m"
<< prefix() <<
" \e[0m"
;
33
return
std::cout
;
34
}
35
36
// ----------------------------------------------------------------------------------------------------
37
38
void
info
(
const
char
* str)
39
{
40
std::cout
<<
"\e[1;37m"
<< prefix() << str <<
" \e[0m"
<<
std::endl
;
41
}
42
43
// ----------------------------------------------------------------------------------------------------
44
45
void
info
(
const
std::string
& str)
46
{
47
info
(str.
c_str
());
48
}
49
50
// ----------------------------------------------------------------------------------------------------
51
52
std::ostream
&
warning
()
53
{
54
std::cout
<<
"\e[1;33m"
<< prefix() <<
"Warning: \e[0m"
;
55
return
std::cout
;
56
}
57
58
// ----------------------------------------------------------------------------------------------------
59
60
void
warning
(
const
char
* str)
61
{
62
std::cout
<<
"\e[1;33m"
<< prefix() <<
"Warning: \e[0m"
<< str <<
std::endl
;
63
}
64
65
// ----------------------------------------------------------------------------------------------------
66
67
void
warning
(
const
std::string
& str)
68
{
69
warning
(str.
c_str
());
70
}
71
72
// ----------------------------------------------------------------------------------------------------
73
74
std::ostream
&
error
()
75
{
76
std::cout
<<
"\e[1;31m"
<< prefix() <<
"Error: \e[0m"
;
77
return
std::cout
;
78
}
79
80
// ----------------------------------------------------------------------------------------------------
81
82
void
error
(
const
char
* str)
83
{
84
std::cout
<<
"\e[1;31m"
<< prefix() <<
"Error: \e[0m"
<< str <<
std::endl
;
85
}
86
87
// ----------------------------------------------------------------------------------------------------
88
89
void
error
(
const
std::string
& str)
90
{
91
error
(str.
c_str
());
92
}
93
94
// ----------------------------------------------------------------------------------------------------
95
96
}
97
98
}
std::string
iostream
std::cout
std::log
T log(T... args)
ed::log::info
std::ostream & info()
Definition:
logging.cpp:30
ed::log::error
std::ostream & error()
Definition:
logging.cpp:74
std::ostream
std::string::c_str
T c_str(T... args)
ed::log::warning
std::ostream & warning()
Definition:
logging.cpp:52
std::endl
T endl(T... args)
logging.h
ed
Definition:
convex_hull.h:8
Generated on Sun Feb 23 2025 04:34:40 for ed by
1.8.17