70 lines
2.4 KiB
Diff
70 lines
2.4 KiB
Diff
From 19d44b7ddf8266aabc04b18a0a6eb4716d08f9d0 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
|
|
Date: Wed, 27 Mar 2019 15:08:59 +0100
|
|
Subject: [PATCH 2/3] Add a debug argument to Librepolog::addHandler
|
|
|
|
When set to false (default), only logs messages from INFO up, when true,
|
|
logs all messages, including DEBUG.
|
|
|
|
The argument having a default means the change is compatible with older
|
|
consumers of the API, but the bahaviour will be changed, the debug
|
|
messages will not be logged anymore.
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1580022
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1678598
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1355764
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1695720
|
|
|
|
backport from:
|
|
https://github.com/rpm-software-management/libdnf/pull/707/commits/daa9d69f98c96de54966905e80c4caa95f50d587
|
|
---
|
|
libdnf/repo/Repo.cpp | 11 +++++++++--
|
|
libdnf/repo/Repo.hpp | 2 +-
|
|
2 files changed, 10 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp
|
|
index 2844bfe..2c28541 100644
|
|
--- a/libdnf/repo/Repo.cpp
|
|
+++ b/libdnf/repo/Repo.cpp
|
|
@@ -1740,7 +1740,7 @@ static void librepoLogCB(G_GNUC_UNUSED const gchar *log_domain, GLogLevelFlags l
|
|
}
|
|
}
|
|
|
|
-long LibrepoLog::addHandler(const std::string & filePath)
|
|
+long LibrepoLog::addHandler(const std::string & filePath, bool debug)
|
|
{
|
|
static long uid = 0;
|
|
|
|
@@ -1755,7 +1755,14 @@ long LibrepoLog::addHandler(const std::string & filePath)
|
|
data->fd = fd;
|
|
|
|
// Set handler
|
|
- data->handlerId = g_log_set_handler(LR_LOGDOMAIN, G_LOG_LEVEL_MASK, librepoLogCB, data.get());
|
|
+ GLogLevelFlags log_mask = debug ? G_LOG_LEVEL_MASK : static_cast<GLogLevelFlags>(
|
|
+ G_LOG_LEVEL_INFO |
|
|
+ G_LOG_LEVEL_MESSAGE |
|
|
+ G_LOG_LEVEL_WARNING |
|
|
+ G_LOG_LEVEL_CRITICAL |
|
|
+ G_LOG_LEVEL_ERROR);
|
|
+
|
|
+ data->handlerId = g_log_set_handler(LR_LOGDOMAIN, log_mask, librepoLogCB, data.get());
|
|
data->used = true;
|
|
|
|
// Save user data (in a thread safe way)
|
|
diff --git a/libdnf/repo/Repo.hpp b/libdnf/repo/Repo.hpp
|
|
index 06e94f6..d5bef20 100644
|
|
--- a/libdnf/repo/Repo.hpp
|
|
+++ b/libdnf/repo/Repo.hpp
|
|
@@ -296,7 +296,7 @@ private:
|
|
|
|
struct LibrepoLog {
|
|
public:
|
|
- static long addHandler(const std::string & filePath);
|
|
+ static long addHandler(const std::string & filePath, bool debug = false);
|
|
static void removeHandler(long uid);
|
|
static void removeAllHandlers();
|
|
};
|
|
--
|
|
2.19.1
|
|
|