mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-16 11:45:59 +01:00
34 lines
814 B
C++
34 lines
814 B
C++
#include "Log.hpp"
|
|
#include "../defines.hpp"
|
|
#include "../Compositor.hpp"
|
|
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
void Debug::init(const std::string& IS) {
|
|
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
|
}
|
|
|
|
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
|
|
if (level > wlr_log_get_verbosity())
|
|
return;
|
|
|
|
char* outputStr = nullptr;
|
|
|
|
vasprintf(&outputStr, fmt, args);
|
|
|
|
std::string output = std::string(outputStr);
|
|
free(outputStr);
|
|
|
|
rollingLog += output + "\n";
|
|
|
|
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";
|
|
}
|