summaryrefslogtreecommitdiffstats
path: root/synchronizer
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
commitda2b049e248c1ad7efeb53685158a205335e4e36 (patch)
tree1e7e5e940e9b760b2108081b1d2f3879cebdb0ff /synchronizer
parent9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (diff)
downloadsink-da2b049e248c1ad7efeb53685158a205335e4e36.tar.gz
sink-da2b049e248c1ad7efeb53685158a205335e4e36.zip
A new debug system.
Instead of a single #define as debug area the new system allows for an identifier for each debug message with the structure component.area. The component is a dot separated identifier of the runtime component, such as the process or the plugin. The area is the code component, and can be as such defined at compiletime. The idea of this system is that it becomes possible to i.e. look at the output of all messages in the query subsystem of a specific resource (something that happens in the client process, but in the resource-specific subcomponent). The new macros are supposed to be less likely to clash with other names, hence the new names.
Diffstat (limited to 'synchronizer')
-rw-r--r--synchronizer/main.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp
index b3decf6..e9dd6cb 100644
--- a/synchronizer/main.cpp
+++ b/synchronizer/main.cpp
@@ -34,8 +34,7 @@
34#include "log.h" 34#include "log.h"
35#include "test.h" 35#include "test.h"
36 36
37#undef DEBUG_AREA 37SINK_DEBUG_AREA("main")
38#define DEBUG_AREA "resource"
39 38
40static Listener *listener = nullptr; 39static Listener *listener = nullptr;
41 40
@@ -149,13 +148,13 @@ int main(int argc, char *argv[])
149 arguments << argv[i]; 148 arguments << argv[i];
150 } 149 }
151 if (arguments.contains("--test")) { 150 if (arguments.contains("--test")) {
152 Log() << "Running in test-mode"; 151 SinkLog() << "Running in test-mode";
153 arguments.removeAll("--test"); 152 arguments.removeAll("--test");
154 Sink::Test::setTestModeEnabled(true); 153 Sink::Test::setTestModeEnabled(true);
155 } 154 }
156 155
157 if (arguments.count() < 3) { 156 if (arguments.count() < 3) {
158 Warning() << "Not enough args passed, no resource loaded."; 157 SinkWarning() << "Not enough args passed, no resource loaded.";
159 return app.exec(); 158 return app.exec();
160 } 159 }
161 160
@@ -163,12 +162,12 @@ int main(int argc, char *argv[])
163 const QByteArray resourceType = arguments.at(2); 162 const QByteArray resourceType = arguments.at(2);
164 app.setApplicationName(instanceIdentifier); 163 app.setApplicationName(instanceIdentifier);
165 Sink::Log::setPrimaryComponent(instanceIdentifier); 164 Sink::Log::setPrimaryComponent(instanceIdentifier);
166 Log() << "Starting: " << instanceIdentifier; 165 SinkLog() << "Starting: " << instanceIdentifier;
167 166
168 QLockFile lockfile(instanceIdentifier + ".lock"); 167 QLockFile lockfile(instanceIdentifier + ".lock");
169 lockfile.setStaleLockTime(500); 168 lockfile.setStaleLockTime(500);
170 if (!lockfile.tryLock(0)) { 169 if (!lockfile.tryLock(0)) {
171 Warning() << "Failed to acquire exclusive lock on socket."; 170 SinkWarning() << "Failed to acquire exclusive lock on socket.";
172 return -1; 171 return -1;
173 } 172 }
174 173
@@ -178,6 +177,6 @@ int main(int argc, char *argv[])
178 QObject::connect(listener, &Listener::noClients, &app, &QCoreApplication::quit); 177 QObject::connect(listener, &Listener::noClients, &app, &QCoreApplication::quit);
179 178
180 auto ret = app.exec(); 179 auto ret = app.exec();
181 Log() << "Exiting: " << instanceIdentifier; 180 SinkLog() << "Exiting: " << instanceIdentifier;
182 return ret; 181 return ret;
183} 182}