Skip to content

Commit 1bd1039

Browse files
committed
add debug logger
1 parent 1c8bdfb commit 1bd1039

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

example/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ int main(int argc, char **argv) {
88

99
logger::success("This is a success message");
1010
logger::info("This is an info message");
11+
logger::debug("This is a debug message");
1112
logger::warning("This is a warning message");
1213
logger::error("This is an error message");
1314
// logger::error("This is an error message with a runtime error message",

include/logger/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace logger {
88
#define GREEN "\033[1;32m"
99
#define YELLOW "\033[1;33m"
1010
#define BLUE "\033[1;36m"
11+
#define MAGENTA "\033[1;35m"
1112
#define RESET "\033[0m"
1213

1314
extern bool ENABLED;

include/logger/log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ void success(const std::string message, bool newline = true);
1313

1414
void info(const std::string message, bool newline = true);
1515

16+
void debug(const std::string message, bool newline = true);
17+
1618
void warning(const std::string message, bool newline = true);
1719

1820
void error(const std::string message,

src/log.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ void logger::info(const std::string message, bool newline) {
3030
std::cout.flush();
3131
}
3232

33+
void logger::debug(const std::string message, bool newline) {
34+
if (ENABLED) {
35+
std::cout << getTime();
36+
if (BEAUTIFY)
37+
std::cout << MAGENTA;
38+
std::cout << "[DEBUG] ";
39+
if (BEAUTIFY)
40+
std::cout << RESET;
41+
std::cout << ": " << message;
42+
if (newline)
43+
std::cout << "\n";
44+
}
45+
std::cout.flush();
46+
}
47+
3348
void logger::warning(const std::string message, bool newline) {
3449
if (ENABLED) {
3550
std::cout << getTime();

0 commit comments

Comments
 (0)