Skip to content

Commit 9271162

Browse files
committed
ui: drop toolkit's log level by default via a log conn
1 parent 01e9c1f commit 9271162

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/helpers/GlobalState.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include "Memory.hpp"
4+
5+
struct SGlobalState {
6+
bool verbose = false;
7+
};
8+
9+
inline UP<SGlobalState> g_state = makeUnique<SGlobalState>();

src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "defines.hpp"
22
#include "helpers/Logger.hpp"
3+
#include "helpers/GlobalState.hpp"
34
#include "ui/UI.hpp"
45
#include "config/ConfigManager.hpp"
56

@@ -25,8 +26,10 @@ int main(int argc, const char** argv, const char** envp) {
2526
return 0;
2627
}
2728

28-
if (parser.getBool("verbose").value_or(false))
29+
if (parser.getBool("verbose").value_or(false)) {
2930
g_logger->setLogLevel(LOG_TRACE);
31+
g_state->verbose = true;
32+
}
3033

3134
g_logger->log(LOG_DEBUG, "Welcome to hyprpaper!\nbuilt from commit {} ({})", GIT_COMMIT_HASH, GIT_COMMIT_MESSAGE);
3235

src/ui/UI.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "UI.hpp"
22
#include "../defines.hpp"
33
#include "../helpers/Logger.hpp"
4+
#include "../helpers/GlobalState.hpp"
45
#include "../ipc/HyprlandSocket.hpp"
56
#include "../ipc/IPC.hpp"
67
#include "../config/WallpaperMatcher.hpp"
@@ -132,7 +133,13 @@ void CUI::registerOutput(const SP<Hyprtoolkit::IOutput>& mon) {
132133
bool CUI::run() {
133134
static const auto PENABLEIPC = Hyprlang::CSimpleConfigValue<Hyprlang::INT>(g_config->hyprlang(), "ipc");
134135

135-
m_backend = Hyprtoolkit::IBackend::create();
136+
//
137+
Hyprtoolkit::IBackend::SBackendCreationData data;
138+
data.pLogConnection = makeShared<Hyprutils::CLI::CLoggerConnection>(*g_logger);
139+
data.pLogConnection->setName("hyprtoolkit");
140+
data.pLogConnection->setLogLevel(g_state->verbose ? LOG_TRACE : LOG_ERR);
141+
142+
m_backend = Hyprtoolkit::IBackend::createWithData(data);
136143

137144
if (!m_backend)
138145
return false;

0 commit comments

Comments
 (0)