summaryrefslogtreecommitdiff
path: root/src/debug/Log.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-11-14 20:06:04 +0000
committerVaxry <vaxry@vaxry.net>2023-11-14 20:06:04 +0000
commite195e51c1bd4b17398ec6964f30751b6a54bbb44 (patch)
tree31fc8158f4964943c90df98f02d8459fe37b321e /src/debug/Log.cpp
parente8469f8b1bb184a08351ee3cc3fcc4d0638eb90b (diff)
logging: move to an internal rolling log buffer
disables logging to the logfile by default
Diffstat (limited to 'src/debug/Log.cpp')
-rw-r--r--src/debug/Log.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/debug/Log.cpp b/src/debug/Log.cpp
index 98eeebc9..404904a2 100644
--- a/src/debug/Log.cpp
+++ b/src/debug/Log.cpp
@@ -10,25 +10,24 @@ void Debug::init(const std::string& IS) {
}
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
- if (disableLogs && *disableLogs)
- return;
-
if (level > wlr_log_get_verbosity())
return;
- char* outputStr = nullptr;
-
- std::ofstream ofs;
- ofs.open(logFile, std::ios::out | std::ios::app);
+ char* outputStr = nullptr;
vasprintf(&outputStr, fmt, args);
std::string output = std::string(outputStr);
free(outputStr);
- ofs << "[wlr] " << output << "\n";
+ rollingLog += output + "\n";
- ofs.close();
+ if (!disableLogs || !*disableLogs) {
+ std::ofstream ofs;
+ ofs.open(logFile, std::ios::out | std::ios::app);
+ ofs << "[wlr] " << output << "\n";
+ ofs.close();
+ }
if (!disableStdout)
std::cout << output << "\n";