forked from hyprwm/hyprcursor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
170 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,22 @@ | ||
#pragma once | ||
|
||
enum eLogLevel { | ||
TRACE = 0, | ||
INFO, | ||
LOG, | ||
WARN, | ||
ERR, | ||
CRIT, | ||
NONE | ||
}; | ||
|
||
#include <string> | ||
#include <format> | ||
#include <iostream> | ||
|
||
#include <hyprcursor/shared.h> | ||
|
||
namespace Debug { | ||
inline bool quiet = false; | ||
inline bool verbose = false; | ||
|
||
template <typename... Args> | ||
void log(eLogLevel level, const std::string& fmt, Args&&... args) { | ||
|
||
#ifndef HYPRLAND_DEBUG | ||
// don't log in release | ||
return; | ||
#endif | ||
|
||
if (!verbose && level == TRACE) | ||
void log(eHyprcursorLogLevel level, PHYPRCURSORLOGFUNC fn, const std::string& fmt, Args&&... args) { | ||
if (!fn) | ||
return; | ||
|
||
if (quiet) | ||
return; | ||
|
||
if (level != NONE) { | ||
std::cout << '['; | ||
|
||
switch (level) { | ||
case TRACE: std::cout << "TRACE"; break; | ||
case INFO: std::cout << "INFO"; break; | ||
case LOG: std::cout << "LOG"; break; | ||
case WARN: std::cout << "WARN"; break; | ||
case ERR: std::cout << "ERR"; break; | ||
case CRIT: std::cout << "CRITICAL"; break; | ||
default: break; | ||
} | ||
|
||
std::cout << "] "; | ||
} | ||
const std::string LOG = std::vformat(fmt, std::make_format_args(args...)); | ||
|
||
std::cout << std::vformat(fmt, std::make_format_args(args...)) << "\n"; | ||
fn(level, (char*)LOG.c_str()); | ||
} | ||
}; |
Oops, something went wrong.