Skip to content

Commit 9486a23

Browse files
committed
Log to the instance folder
1 parent 6f3b004 commit 9486a23

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

src/Compositor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
CCompositor::CCompositor() {
44
m_szInstanceSignature = GIT_COMMIT_HASH + std::string("_") + std::to_string(time(NULL));
55

6+
Debug::init(m_szInstanceSignature);
7+
68
Debug::log(LOG, "Instance Signature: %s", m_szInstanceSignature.c_str());
79

810
setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true);

src/debug/Log.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#include "Log.hpp"
22
#include "../defines.hpp"
3+
#include "../Compositor.hpp"
34

45
#include <fstream>
56
#include <iostream>
67

7-
void Debug::init() {
8+
void Debug::init(std::string IS) {
89
if (ISDEBUG)
9-
logFile = "/tmp/hypr/hyprlandd-" + std::to_string(time(NULL)) + ".log";
10+
logFile = "/tmp/hypr/" + IS + "/hyprlandd.log";
1011
else
11-
logFile = "/tmp/hypr/hyprland-" + std::to_string(time(NULL)) + ".log";
12+
logFile = "/tmp/hypr/" + IS + "/hyprland.log";
1213
}
1314

1415
void Debug::log(LogLevel level, const char* fmt, ...) {

src/debug/Log.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum LogLevel {
1212
};
1313

1414
namespace Debug {
15-
void init();
15+
void init(std::string IS);
1616
void log(LogLevel level, const char* fmt, ...);
1717

1818
inline std::string logFile;

src/main.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Compositor.hpp"
44
#include "config/ConfigManager.hpp"
55
#include "init/initHelpers.hpp"
6+
#include <iostream>
67

78
// I am a bad bad boy and have used some global vars here,
89
// just for this file
@@ -21,19 +22,17 @@ int main(int argc, char** argv) {
2122

2223
system("mkdir -p /tmp/hypr");
2324

24-
Debug::init();
25-
2625
if (!ignoreSudo) {
2726
if (Init::isSudo()) {
28-
Debug::log(CRIT, "Hyprland shall not be run as the root user. If you really want to, use the --i-am-really-stupid flag.");
29-
return 1;
27+
std::cout << "Hyprland shall not be run as the root user. If you really want to, use the --i-am-really-stupid flag.\n";
28+
return 1;
3029
}
3130
} else {
32-
Debug::log(WARN, "Running with ignored root checks, I surely hope you know what you're doing.");
31+
std::cout << "Running with ignored root checks, I surely hope you know what you're doing.\n";
3332
sleep(1);
3433
}
3534

36-
Debug::log(LOG, "Welcome to Hyprland!");
35+
std::cout << "Welcome to Hyprland!\n";
3736

3837
// let's init the compositor.
3938
// it initializes basic Wayland stuff in the constructor.

0 commit comments

Comments
 (0)