Merge lp:~mandel/ubuntu-download-manager/client-logging into lp:ubuntu-download-manager
- client-logging
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Manuel de la Peña |
Approved revision: | 326 |
Merged at revision: | 308 |
Proposed branch: | lp:~mandel/ubuntu-download-manager/client-logging |
Merge into: | lp:ubuntu-download-manager |
Prerequisite: | lp:~mandel/ubuntu-download-manager/set-headers-dbus-method |
Diff against target: |
1390 lines (+611/-108) 18 files modified
CMakeLists.txt (+2/-1) debian/changelog (+8/-0) debian/control (+1/-0) debian/libubuntu-download-manager-client0.symbols (+1/-0) src/common/public/ubuntu/transfers/system/logger.cpp (+1/-0) src/downloads/client/CMakeLists.txt (+18/-13) src/downloads/client/symbols.map (+6/-0) src/downloads/client/ubuntu/download_manager/download_impl.cpp (+114/-25) src/downloads/client/ubuntu/download_manager/download_impl.h (+6/-3) src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp (+23/-13) src/downloads/client/ubuntu/download_manager/logging/logger.cpp (+213/-0) src/downloads/client/ubuntu/download_manager/logging/logger.h (+106/-0) src/downloads/client/ubuntu/download_manager/manager.cpp (+2/-3) src/downloads/client/ubuntu/download_manager/manager_impl.cpp (+50/-18) src/downloads/client/ubuntu/download_manager/manager_impl.h (+8/-6) src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp (+48/-26) tests/local_tree_testcase.cpp (+2/-0) tests/local_tree_testcase.h (+2/-0) |
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/client-logging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Sheldon (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+225021@code.launchpad.net |
Commit message
Add a loger class that can be used by the clients to set the logging type.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
- 324. By Manuel de la Peña
-
Hide priv documentation.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:324
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 325. By Manuel de la Peña
-
Initialize pointer to null.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:325
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 326. By Manuel de la Peña
-
Fix cmake and remove the need to linking against glog for the client library.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:326
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Michael Sheldon (michael-sheldon) wrote : | # |
Looks good to me, only had one note on the naming of a couple of functions (see diff comments), but that's as much a matter of personal preference as anything.
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2014-07-03 10:39:05 +0000 |
3 | +++ CMakeLists.txt 2014-07-03 10:39:06 +0000 |
4 | @@ -31,7 +31,7 @@ |
5 | ) |
6 | |
7 | set(UDM_VERSION_MAJOR 0) |
8 | -set(UDM_VERSION_MINOR 5) |
9 | +set(UDM_VERSION_MINOR 6) |
10 | set(UDM_VERSION_PATCH 0) |
11 | |
12 | find_package(Gtest REQUIRED) |
13 | @@ -46,6 +46,7 @@ |
14 | find_package(Qt5SystemInfo REQUIRED) |
15 | find_package(Qt5Sql REQUIRED) |
16 | find_package(Qt5Test REQUIRED) |
17 | +find_package(Boost COMPONENTS log REQUIRED) |
18 | |
19 | find_package(PkgConfig REQUIRED) |
20 | pkg_check_modules(DBUS REQUIRED dbus-1) |
21 | |
22 | === modified file 'debian/changelog' |
23 | --- debian/changelog 2014-07-03 10:39:05 +0000 |
24 | +++ debian/changelog 2014-07-03 10:39:06 +0000 |
25 | @@ -1,3 +1,11 @@ |
26 | +ubuntu-download-manager (0.6) UNRELEASED; urgency=medium |
27 | + |
28 | + * Add a new public object in the client library that provides a way |
29 | + to configure the logging done in the client library. ABI is changed |
30 | + and a new dependency is added. |
31 | + |
32 | + -- Manuel de la Pena <manuel.delapena@canonical.com> Thu, 26 Jun 2014 13:00:45 +0200 |
33 | + |
34 | ubuntu-download-manager (0.5) UNRELEASED; urgency=medium |
35 | |
36 | * Add support to set the headers for a single file download. This change |
37 | |
38 | === modified file 'debian/control' |
39 | --- debian/control 2014-04-30 14:59:42 +0000 |
40 | +++ debian/control 2014-07-03 10:39:06 +0000 |
41 | @@ -10,6 +10,7 @@ |
42 | qt5-default, |
43 | qtbase5-dev, |
44 | qtsystems5-dev, |
45 | + libboost-log-dev, |
46 | libdbus-1-dev, |
47 | libqt5sql5-sqlite, |
48 | libnih-dbus-dev, |
49 | |
50 | === modified file 'debian/libubuntu-download-manager-client0.symbols' |
51 | --- debian/libubuntu-download-manager-client0.symbols 2014-06-18 14:49:04 +0000 |
52 | +++ debian/libubuntu-download-manager-client0.symbols 2014-07-03 10:39:06 +0000 |
53 | @@ -24,6 +24,7 @@ |
54 | (c++)"Ubuntu::DownloadManager::ProcessError::~ProcessError()@Base" 0.4+14.10.20140618 |
55 | (c++)"Ubuntu::DownloadManager::ProcessError::~ProcessError()@Base" 0.4+14.10.20140618 |
56 | (c++)"Ubuntu::DownloadManager::ProcessError::~ProcessError()@Base" 0.4+14.10.20140618 |
57 | + (c++)"Ubuntu::DownloadManager::Logging::Logger::init(Ubuntu::DownloadManager::Logging::Logger::Level, QString const&)@Base" 0replaceme |
58 | (c++)"Ubuntu::DownloadManager::DownloadsList::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.4+14.10.20140618 |
59 | (c++)"Ubuntu::DownloadManager::DownloadsList::qt_metacast(char const*)@Base" 0.4+14.10.20140618 |
60 | (c++)"Ubuntu::DownloadManager::DownloadsList::staticMetaObject@Base" 0.4+14.10.20140618 |
61 | |
62 | === modified file 'src/common/public/ubuntu/transfers/system/logger.cpp' |
63 | --- src/common/public/ubuntu/transfers/system/logger.cpp 2014-03-28 15:50:24 +0000 |
64 | +++ src/common/public/ubuntu/transfers/system/logger.cpp 2014-07-03 10:39:06 +0000 |
65 | @@ -118,6 +118,7 @@ |
66 | google::SetLogDestination(google::ERROR, toStdString(path).c_str()); |
67 | google::SetLogDestination(google::WARNING, toStdString(path).c_str()); |
68 | google::SetLogDestination(google::INFO, toStdString(path).c_str()); |
69 | + google::SetLogDestination(google::FATAL, toStdString(path).c_str()); |
70 | } |
71 | } |
72 | |
73 | |
74 | === modified file 'src/downloads/client/CMakeLists.txt' |
75 | --- src/downloads/client/CMakeLists.txt 2014-06-17 10:23:15 +0000 |
76 | +++ src/downloads/client/CMakeLists.txt 2014-07-03 10:39:06 +0000 |
77 | @@ -1,9 +1,11 @@ |
78 | +add_definitions(-DBOOST_LOG_DYN_LINK) |
79 | + |
80 | set(TARGET ubuntu-download-manager-client) |
81 | |
82 | set(SOURCES |
83 | ubuntu/download_manager/download_impl.cpp |
84 | ubuntu/download_manager/download_interface.cpp |
85 | - ubuntu/download_manager/downloads_list_impl.cpp |
86 | + ubuntu/download_manager/downloads_list_impl.cpp |
87 | ubuntu/download_manager/download_pendingcall_watcher.cpp |
88 | ubuntu/download_manager/error.cpp |
89 | ubuntu/download_manager/group_download.cpp |
90 | @@ -11,21 +13,23 @@ |
91 | ubuntu/download_manager/manager_impl.cpp |
92 | ubuntu/download_manager/manager_interface.cpp |
93 | ubuntu/download_manager/manager_pendingcall_watcher.cpp |
94 | + ubuntu/download_manager/logging/logger.cpp |
95 | ubuntu/download_manager/pending_call_watcher.cpp |
96 | ) |
97 | |
98 | set(PUBLIC_HEADERS |
99 | ubuntu/download_manager/download.h |
100 | - ubuntu/download_manager/downloads_list.h |
101 | + ubuntu/download_manager/downloads_list.h |
102 | ubuntu/download_manager/error.h |
103 | ubuntu/download_manager/group_download.h |
104 | ubuntu/download_manager/manager.h |
105 | + ubuntu/download_manager/logging/logger.h |
106 | ) |
107 | |
108 | set(PRIVATE_HEADERS |
109 | ubuntu/download_manager/download_impl.h |
110 | ubuntu/download_manager/download_interface.h |
111 | - ubuntu/download_manager/downloads_list_impl.h |
112 | + ubuntu/download_manager/downloads_list_impl.h |
113 | ubuntu/download_manager/download_pendingcall_watcher.h |
114 | ubuntu/download_manager/manager_impl.h |
115 | ubuntu/download_manager/manager_interface.h |
116 | @@ -37,30 +41,31 @@ |
117 | include_directories(${Qt5Network_INCLUDE_DIRS}) |
118 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
119 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
120 | +include_directories(${Boost_INCLUDE_DIRS}) |
121 | include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
122 | include_directories(${CMAKE_SOURCE_DIR}/src/downloads/common) |
123 | |
124 | add_library(${TARGET} SHARED |
125 | - ${SOURCES} |
126 | - ${PUBLIC_HEADERS} |
127 | - ${PRIVATE_HEADERS} |
128 | + ${SOURCES} |
129 | + ${PUBLIC_HEADERS} |
130 | + ${PRIVATE_HEADERS} |
131 | ) |
132 | |
133 | set(symbol_map "${CMAKE_SOURCE_DIR}/src/downloads/client/symbols.map") |
134 | set_target_properties( |
135 | - ${TARGET} |
136 | + ${TARGET} |
137 | |
138 | - PROPERTIES |
139 | + PROPERTIES |
140 | LINK_FLAGS "${ldflags} -Wl,--version-script,${symbol_map}" |
141 | LINK_DEPENDS ${symbol_map} |
142 | - VERSION ${UDM_VERSION_MAJOR}.${UDM_VERSION_MINOR}.${UDM_VERSION_PATCH} |
143 | - SOVERSION ${UDM_VERSION_MAJOR} |
144 | + VERSION ${UDM_VERSION_MAJOR}.${UDM_VERSION_MINOR}.${UDM_VERSION_PATCH} |
145 | + SOVERSION ${UDM_VERSION_MAJOR} |
146 | ) |
147 | |
148 | target_link_libraries(${TARGET} |
149 | - ${Qt5DBus_LIBRARIES} |
150 | - ${GLOG_LIBRARIES} |
151 | - udm-common |
152 | + ${Boost_LIBRARIES} |
153 | + ${Qt5DBus_LIBRARIES} |
154 | + udm-common |
155 | ubuntu-download-manager-common |
156 | ) |
157 | |
158 | |
159 | === modified file 'src/downloads/client/symbols.map' |
160 | --- src/downloads/client/symbols.map 2014-06-17 10:23:15 +0000 |
161 | +++ src/downloads/client/symbols.map 2014-07-03 10:39:06 +0000 |
162 | @@ -11,6 +11,7 @@ |
163 | Ubuntu::DownloadManager::ProcessError::*; |
164 | Ubuntu::DownloadManager::GroupDownload::*; |
165 | Ubuntu::DownloadManager::Manager::*; |
166 | + Ubuntu::DownloadManager::Logging::Logger::init*; |
167 | typeinfo?for?Ubuntu::DownloadManager::Download; |
168 | typeinfo?for?Ubuntu::DownloadManager::DownloadsList; |
169 | typeinfo?for?Ubuntu::DownloadManager::Error; |
170 | @@ -21,6 +22,7 @@ |
171 | typeinfo?for?Ubuntu::DownloadManager::ProcessError; |
172 | typeinfo?for?Ubuntu::DownloadManager::GroupDownload; |
173 | typeinfo?for?Ubuntu::DownloadManager::Manager; |
174 | + typeinfo?for?Ubuntu::DownloadManager::Logging::Logger; |
175 | typeinfo?name?for?Ubuntu::DownloadManager::Download; |
176 | typeinfo?name?for?Ubuntu::DownloadManager::DownloadsList; |
177 | typeinfo?name?for?Ubuntu::DownloadManager::Error; |
178 | @@ -31,6 +33,7 @@ |
179 | typeinfo?name?for?Ubuntu::DownloadManager::ProcessError; |
180 | typeinfo?name?for?Ubuntu::DownloadManager::GroupDownload; |
181 | typeinfo?name?for?Ubuntu::DownloadManager::Manager; |
182 | + typeinfo?name?for?Ubuntu::DownloadManager::Logging::Logger; |
183 | VTT?for?Ubuntu::DownloadManager::Download; |
184 | VTT?for?Ubuntu::DownloadManager::DownloadsList; |
185 | VTT?for?Ubuntu::DownloadManager::Error; |
186 | @@ -41,6 +44,7 @@ |
187 | VTT?for?Ubuntu::DownloadManager::ProcessError; |
188 | VTT?for?Ubuntu::DownloadManager::GroupDownload; |
189 | VTT?for?Ubuntu::DownloadManager::Manager; |
190 | + VTT?for?Ubuntu::DownloadManager::Logging::Logger; |
191 | virtual?thunk?to?Ubuntu::DownloadManager::Download; |
192 | virtual?thunk?to?Ubuntu::DownloadManager::DownloadsList; |
193 | virtual?thunk?to?Ubuntu::DownloadManager::Error; |
194 | @@ -51,6 +55,7 @@ |
195 | virtual?thunk?to?Ubuntu::DownloadManager::ProcessError; |
196 | virtual?thunk?to?Ubuntu::DownloadManager::GroupDownload; |
197 | virtual?thunk?to?Ubuntu::DownloadManager::Manager; |
198 | + virtual?thunk?to?Ubuntu::DownloadManager::Logging::Logger; |
199 | vtable?for?Ubuntu::DownloadManager::Download; |
200 | vtable?for?Ubuntu::DownloadManager::DownloadsList; |
201 | vtable?for?Ubuntu::DownloadManager::Error; |
202 | @@ -61,6 +66,7 @@ |
203 | vtable?for?Ubuntu::DownloadManager::ProcessError; |
204 | vtable?for?Ubuntu::DownloadManager::GroupDownload; |
205 | vtable?for?Ubuntu::DownloadManager::Manager; |
206 | + vtable?for?Ubuntu::DownloadManager::Logging::Logger; |
207 | std::function* |
208 | }; |
209 | |
210 | |
211 | === modified file 'src/downloads/client/ubuntu/download_manager/download_impl.cpp' |
212 | --- src/downloads/client/ubuntu/download_manager/download_impl.cpp 2014-07-03 10:39:05 +0000 |
213 | +++ src/downloads/client/ubuntu/download_manager/download_impl.cpp 2014-07-03 10:39:06 +0000 |
214 | @@ -16,13 +16,15 @@ |
215 | * Boston, MA 02110-1301, USA. |
216 | */ |
217 | |
218 | -#include <glog/logging.h> |
219 | +#include <ubuntu/download_manager/logging/logger.h> |
220 | #include "download_impl.h" |
221 | |
222 | namespace Ubuntu { |
223 | |
224 | namespace DownloadManager { |
225 | |
226 | +using namespace Logging; |
227 | + |
228 | DownloadImpl::DownloadImpl(const QDBusConnection& conn, |
229 | const QString& servicePath, |
230 | const QDBusObjectPath& objectPath, |
231 | @@ -31,38 +33,92 @@ |
232 | _id(objectPath.path()), |
233 | _conn(conn), |
234 | _servicePath(servicePath) { |
235 | + |
236 | _dbusInterface = new DownloadInterface(servicePath, |
237 | _id, conn); |
238 | |
239 | // fwd all the signals but the error one |
240 | - CHECK(connect(_dbusInterface, &DownloadInterface::canceled, |
241 | - this, &Download::canceled)) << "Could not connect to signal"; |
242 | - CHECK(connect(_dbusInterface, &DownloadInterface::finished, |
243 | - this, &Download::finished)) << "Could not connect to signal"; |
244 | - CHECK(connect(_dbusInterface, &DownloadInterface::paused, |
245 | - this, &Download::paused)) << "Could not connect to signal"; |
246 | - CHECK(connect(_dbusInterface, &DownloadInterface::processing, |
247 | - this, &Download::processing)) << "Could not connect to signal"; |
248 | - CHECK(connect(_dbusInterface, static_cast<void(DownloadInterface::*) |
249 | + auto connected = connect(_dbusInterface, &DownloadInterface::canceled, |
250 | + this, &Download::canceled); |
251 | + |
252 | + if (!connected) { |
253 | + Logger::log(Logger::Critical, |
254 | + "Could not connect to signal DownloadInterface::canceled"); |
255 | + } |
256 | + |
257 | + connected = connect(_dbusInterface, &DownloadInterface::finished, |
258 | + this, &Download::finished); |
259 | + if (!connected) { |
260 | + Logger::log(Logger::Critical, |
261 | + "Could not connect to signal &DownloadInterface::finished"); |
262 | + } |
263 | + |
264 | + connected = connect(_dbusInterface, &DownloadInterface::paused, |
265 | + this, &Download::paused); |
266 | + if (!connected) { |
267 | + Logger::log(Logger::Critical, |
268 | + "Could not connect to signal DownloadInterface::paused"); |
269 | + } |
270 | + |
271 | + connected = connect(_dbusInterface, &DownloadInterface::processing, |
272 | + this, &Download::processing); |
273 | + if (!connected) { |
274 | + Logger::log(Logger::Critical, |
275 | + "Could not connect to signal DownloadInterface::processing"); |
276 | + } |
277 | + |
278 | + connected = connect(_dbusInterface, static_cast<void(DownloadInterface::*) |
279 | (qulonglong, qulonglong)>(&DownloadInterface::progress), |
280 | this, static_cast<void(Download::*) |
281 | - (qulonglong, qulonglong)>(&Download::progress))) |
282 | - << "Could not connect to signal"; |
283 | - CHECK(connect(_dbusInterface, &DownloadInterface::resumed, |
284 | - this, &Download::resumed)) << "Could not connect to signal"; |
285 | - CHECK(connect(_dbusInterface, &DownloadInterface::started, |
286 | - this, &Download::started)) << "Could not connect to signal"; |
287 | + (qulonglong, qulonglong)>(&Download::progress)); |
288 | + if (!connected) { |
289 | + Logger::log(Logger::Critical, |
290 | + "Could not connect to signal &DownloadInterface::progress"); |
291 | + } |
292 | + |
293 | + connected = connect(_dbusInterface, &DownloadInterface::resumed, |
294 | + this, &Download::resumed); |
295 | + if (!connected) { |
296 | + Logger::log(Logger::Critical, |
297 | + "Could not connect to signal &DownloadInterface::resumed"); |
298 | + } |
299 | + |
300 | + connected = connect(_dbusInterface, &DownloadInterface::started, |
301 | + this, &Download::started); |
302 | + if (!connected) { |
303 | + Logger::log(Logger::Critical, |
304 | + "Could not connect to signal &DownloadInterface::started"); |
305 | + } |
306 | |
307 | // connect to the different type of errors that will later be converted to |
308 | // the error type to be used by the client. |
309 | - CHECK(connect(_dbusInterface, &DownloadInterface::httpError, |
310 | - this, &DownloadImpl::onHttpError)) << "Could not connect to signal"; |
311 | - CHECK(connect(_dbusInterface, &DownloadInterface::networkError, |
312 | - this, &DownloadImpl::onNetworkError)) << "Could not connect to signal"; |
313 | - CHECK(connect(_dbusInterface, &DownloadInterface::processError, |
314 | - this, &DownloadImpl::onProcessError)) << "Could not connect to signal"; |
315 | - CHECK(connect(_dbusInterface, &DownloadInterface::authError, |
316 | - this, &DownloadImpl::onAuthError)) << "Could not connect to signal"; |
317 | + connected = connect(_dbusInterface, &DownloadInterface::httpError, |
318 | + this, &DownloadImpl::onHttpError); |
319 | + if (!connected) { |
320 | + Logger::log(Logger::Critical, |
321 | + "Could not connect to signal &DownloadInterface::httpError"); |
322 | + } |
323 | + |
324 | + connected = connect(_dbusInterface, &DownloadInterface::networkError, |
325 | + this, &DownloadImpl::onNetworkError); |
326 | + if (!connected) { |
327 | + Logger::log(Logger::Critical, |
328 | + "Could not connect to signal &DownloadInterface::networkError"); |
329 | + } |
330 | + |
331 | + connected = connect(_dbusInterface, &DownloadInterface::processError, |
332 | + this, &DownloadImpl::onProcessError); |
333 | + if (!connected) { |
334 | + Logger::log(Logger::Critical, |
335 | + "Could not connect to signal &DownloadInterface::processError"); |
336 | + } |
337 | + |
338 | + connected = connect(_dbusInterface, &DownloadInterface::authError, |
339 | + this, &DownloadImpl::onAuthError); |
340 | + if (!connected) { |
341 | + Logger::log(Logger::Critical, |
342 | + "Could not connect to signal &DownloadInterface::authError"); |
343 | + } |
344 | } |
345 | |
346 | DownloadImpl::DownloadImpl(const QDBusConnection& conn, Error* err, QObject* parent) |
347 | @@ -79,6 +135,9 @@ |
348 | |
349 | void |
350 | DownloadImpl::setLastError(Error* err) { |
351 | + Logger::log(Logger::Debug, |
352 | + QString("Download{%1} setLastError(%2)").arg(_id).arg( |
353 | + err->errorString())); |
354 | if (_lastError != nullptr) { |
355 | delete _lastError; |
356 | } |
357 | @@ -94,6 +153,7 @@ |
358 | |
359 | void |
360 | DownloadImpl::start() { |
361 | + Logger::log(Logger::Debug, QString("Download{%1} start())").arg(_id)); |
362 | QDBusPendingCall call = |
363 | _dbusInterface->start(); |
364 | auto watcher = new DownloadPCW(_conn, _servicePath, |
365 | @@ -103,6 +163,7 @@ |
366 | |
367 | void |
368 | DownloadImpl::pause() { |
369 | + Logger::log(Logger::Debug, QString("Download{%1} pause())").arg(_id)); |
370 | QDBusPendingCall call = |
371 | _dbusInterface->pause(); |
372 | auto watcher = new DownloadPCW(_conn, _servicePath, |
373 | @@ -112,6 +173,7 @@ |
374 | |
375 | void |
376 | DownloadImpl::resume() { |
377 | + Logger::log(Logger::Debug, QString("Download{%1} resume())").arg(_id)); |
378 | QDBusPendingCall call = |
379 | _dbusInterface->resume(); |
380 | auto watcher = new DownloadPCW(_conn, _servicePath, |
381 | @@ -121,6 +183,7 @@ |
382 | |
383 | void |
384 | DownloadImpl::cancel() { |
385 | + Logger::log(Logger::Debug, QString("Download{%1} cancel())").arg(_id)); |
386 | QDBusPendingCall call = |
387 | _dbusInterface->cancel(); |
388 | auto watcher = new DownloadPCW(_conn, _servicePath, |
389 | @@ -130,22 +193,28 @@ |
390 | |
391 | void |
392 | DownloadImpl::allowMobileDownload(bool allowed) { |
393 | + Logger::log(Logger::Debug, |
394 | + QString("Download{%1} allowMobileDownload%2())").arg(_id).arg(allowed)); |
395 | QDBusPendingReply<> reply = |
396 | _dbusInterface->allowGSMDownload(allowed); |
397 | // block, the call should be fast enough |
398 | reply.waitForFinished(); |
399 | if (reply.isError()) { |
400 | + Logger::log(Logger::Error, "Error when setting mobile data usage"); |
401 | setLastError(reply.error()); |
402 | } |
403 | } |
404 | |
405 | bool |
406 | DownloadImpl::isMobileDownloadAllowed() { |
407 | + Logger::log(Logger::Debug, |
408 | + QString("Download{%1} isMobileDownloadAllowed").arg(_id)); |
409 | QDBusPendingReply<bool> reply = |
410 | _dbusInterface->isGSMDownloadAllowed(); |
411 | // block, the call should be fast enough |
412 | reply.waitForFinished(); |
413 | if (reply.isError()) { |
414 | + Logger::log(Logger::Error, "Error when querying mobile data usage"); |
415 | setLastError(reply.error()); |
416 | return false; |
417 | } else { |
418 | @@ -156,33 +225,42 @@ |
419 | |
420 | void |
421 | DownloadImpl::setDestinationDir(const QString& path) { |
422 | + Logger::log(Logger::Debug, QString("Dowmload{%1} setDestinationDir(%2)") |
423 | + .arg(_id).arg(path)); |
424 | QDBusPendingReply<> reply = |
425 | _dbusInterface->setDestinationDir(path); |
426 | // block, the call should be fast enough |
427 | reply.waitForFinished(); |
428 | if (reply.isError()) { |
429 | + Logger::log(Logger::Error, "Error setting the download directory"); |
430 | setLastError(reply.error()); |
431 | } |
432 | } |
433 | |
434 | void |
435 | DownloadImpl::setHeaders(QMap<QString, QString> headers) { |
436 | + Logger::log(Logger::Debug, |
437 | + QString("Download {%1} setHeaders(%2)").arg(_id), headers); |
438 | + |
439 | QDBusPendingReply<> reply = |
440 | _dbusInterface->setHeaders(headers); |
441 | // block, the call should be fast enough |
442 | reply.waitForFinished(); |
443 | if (reply.isError()) { |
444 | + Logger::log(Logger::Error, "Error setting the download headers"); |
445 | setLastError(reply.error()); |
446 | } |
447 | } |
448 | |
449 | QMap<QString, QString> |
450 | DownloadImpl::headers() { |
451 | + Logger::log(Logger::Debug, QString("Download{%1} headers()").arg(_id)); |
452 | QDBusPendingReply<QMap<QString, QString> > reply = |
453 | _dbusInterface->headers(); |
454 | // block, the call should be fast enough |
455 | reply.waitForFinished(); |
456 | if (reply.isError()) { |
457 | + Logger::log(Logger::Error, "Error querying the download headers"); |
458 | setLastError(reply.error()); |
459 | QMap<QString, QString> empty; |
460 | return empty; |
461 | @@ -195,22 +273,27 @@ |
462 | |
463 | void |
464 | DownloadImpl::setThrottle(qulonglong speed) { |
465 | + Logger::log(Logger::Debug, |
466 | + QString("Download{%1} setThrottle(%2)").arg(_id).arg(speed)); |
467 | QDBusPendingReply<> reply = |
468 | _dbusInterface->setThrottle(speed); |
469 | // block, the call should be fast enough |
470 | reply.waitForFinished(); |
471 | if (reply.isError()) { |
472 | + Logger::log(Logger::Error, "Error setting the download throttle"); |
473 | setLastError(reply.error()); |
474 | } |
475 | } |
476 | |
477 | qulonglong |
478 | DownloadImpl::throttle() { |
479 | + Logger::log(Logger::Debug, QString("Download{%1} throttle()").arg(_id)); |
480 | QDBusPendingReply<qulonglong> reply = |
481 | _dbusInterface->throttle(); |
482 | // block, the call is fast enough |
483 | reply.waitForFinished(); |
484 | if (reply.isError()) { |
485 | + Logger::log(Logger::Error, "Error querying the download throttle"); |
486 | setLastError(reply.error()); |
487 | return 0; |
488 | } else { |
489 | @@ -226,11 +309,13 @@ |
490 | |
491 | QVariantMap |
492 | DownloadImpl::metadata() { |
493 | + Logger::log(Logger::Debug, QString("Download{%1} metadata()").arg(_id)); |
494 | QDBusPendingReply<QVariantMap> reply = |
495 | _dbusInterface->metadata(); |
496 | // block the call is fast enough |
497 | reply.waitForFinished(); |
498 | if (reply.isError()) { |
499 | + Logger::log(Logger::Error, "Error querying the download metadata"); |
500 | QVariantMap emptyResult; |
501 | setLastError(reply.error()); |
502 | return emptyResult; |
503 | @@ -242,11 +327,13 @@ |
504 | |
505 | qulonglong |
506 | DownloadImpl::progress() { |
507 | + Logger::log(Logger::Debug, QString("Download{%1} progress()").arg(_id)); |
508 | QDBusPendingReply<qulonglong> reply = |
509 | _dbusInterface->progress(); |
510 | // block call should be fast enough |
511 | reply.waitForFinished(); |
512 | if (reply.isError()) { |
513 | + Logger::log(Logger::Error, "Error querying the download progress"); |
514 | setLastError(reply.error()); |
515 | return 0; |
516 | } else { |
517 | @@ -257,11 +344,13 @@ |
518 | |
519 | qulonglong |
520 | DownloadImpl::totalSize() { |
521 | + Logger::log(Logger::Debug, QString("Download{%1} totalSize()").arg(_id)); |
522 | QDBusPendingReply<qulonglong> reply = |
523 | _dbusInterface->totalSize(); |
524 | - // block call should b fast enough |
525 | + // block call should be fast enough |
526 | reply.waitForFinished(); |
527 | if (reply.isError()) { |
528 | + Logger::log(Logger::Error, "Error querying the download size"); |
529 | setLastError(reply.error()); |
530 | return 0; |
531 | } else { |
532 | |
533 | === modified file 'src/downloads/client/ubuntu/download_manager/download_impl.h' |
534 | --- src/downloads/client/ubuntu/download_manager/download_impl.h 2014-07-03 10:39:05 +0000 |
535 | +++ src/downloads/client/ubuntu/download_manager/download_impl.h 2014-07-03 10:39:06 +0000 |
536 | @@ -24,11 +24,14 @@ |
537 | #include <QObject> |
538 | #include <QVariantMap> |
539 | #include <QString> |
540 | + |
541 | #include <ubuntu/transfers/visibility.h> |
542 | #include <ubuntu/download_manager/metatypes.h> |
543 | -#include "download_interface.h" |
544 | -#include "download_pendingcall_watcher.h" |
545 | -#include "error.h" |
546 | + |
547 | +#include <ubuntu/download_manager/download_interface.h> |
548 | +#include <ubuntu/download_manager/download_pendingcall_watcher.h> |
549 | +#include <ubuntu/download_manager/error.h> |
550 | + |
551 | #include "download.h" |
552 | |
553 | class QDBusConnection; |
554 | |
555 | === modified file 'src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp' |
556 | --- src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp 2014-04-09 11:10:26 +0000 |
557 | +++ src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp 2014-07-03 10:39:06 +0000 |
558 | @@ -16,25 +16,33 @@ |
559 | * Boston, MA 02110-1301, USA. |
560 | */ |
561 | |
562 | -#include <QDebug> |
563 | #include <QDBusPendingReply> |
564 | -#include <glog/logging.h> |
565 | -#include "error.h" |
566 | -#include "download_pendingcall_watcher.h" |
567 | + |
568 | +#include <boost/log/sources/record_ostream.hpp> |
569 | +#include <boost/log/sources/severity_feature.hpp> |
570 | + |
571 | +#include <ubuntu/download_manager/error.h> |
572 | +#include <ubuntu/download_manager/logging/logger.h> |
573 | + |
574 | +#include <ubuntu/download_manager/download_pendingcall_watcher.h> |
575 | |
576 | namespace Ubuntu { |
577 | |
578 | namespace DownloadManager { |
579 | |
580 | -DownloadPCW::DownloadPCW( |
581 | - const QDBusConnection& conn, |
582 | - const QString& servicePath, |
583 | - const QDBusPendingCall& call, |
584 | - Download* parent) |
585 | +using namespace Logging; |
586 | + |
587 | +DownloadPCW::DownloadPCW(const QDBusConnection& conn, |
588 | + const QString& servicePath, |
589 | + const QDBusPendingCall& call, |
590 | + Download* parent) |
591 | : PendingCallWatcher(conn, servicePath, call, parent) { |
592 | - CHECK(connect(this, &DownloadPCW::finished, |
593 | - this, &DownloadPCW::onFinished)) |
594 | - << "Could not connect to signal"; |
595 | + auto connected = connect(this, &DownloadPCW::finished, |
596 | + this, &DownloadPCW::onFinished); |
597 | + if (!connected) { |
598 | + Logger::log(Logger::Critical, |
599 | + "Could not connect to signal &DownloadPCW::finished"); |
600 | + } |
601 | } |
602 | |
603 | void |
604 | @@ -42,7 +50,9 @@ |
605 | auto down = qobject_cast<Download*>(parent()); |
606 | QDBusPendingReply<> reply = *watcher; |
607 | if (reply.isError()) { |
608 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
609 | + auto dbusErr = reply.error(); |
610 | + Logger::log(Logger::Error, |
611 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
612 | auto err = new DBusError(reply.error()); |
613 | down->error(err); |
614 | } |
615 | |
616 | === added directory 'src/downloads/client/ubuntu/download_manager/logging' |
617 | === added file 'src/downloads/client/ubuntu/download_manager/logging/logger.cpp' |
618 | --- src/downloads/client/ubuntu/download_manager/logging/logger.cpp 1970-01-01 00:00:00 +0000 |
619 | +++ src/downloads/client/ubuntu/download_manager/logging/logger.cpp 2014-07-03 10:39:06 +0000 |
620 | @@ -0,0 +1,213 @@ |
621 | +/* |
622 | + * Copyright 2014 Canonical Ltd. |
623 | + * |
624 | + * This library is free software; you can redistribute it and/or |
625 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
626 | + * License as published by the Free Software Foundation. |
627 | + * |
628 | + * This program is distributed in the hope that it will be useful, |
629 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
630 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
631 | + * General Public License for more details. |
632 | + * |
633 | + * You should have received a copy of the GNU Lesser General Public |
634 | + * License along with this library; if not, write to the |
635 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
636 | + * Boston, MA 02110-1301, USA. |
637 | + */ |
638 | + |
639 | +#include <boost/log/expressions/attr_fwd.hpp> |
640 | +#include <boost/log/expressions/attr.hpp> |
641 | +#include <boost/log/expressions/formatters/date_time.hpp> |
642 | +#include <boost/log/keywords/channel.hpp> |
643 | +#include <boost/log/sources/severity_channel_logger.hpp> |
644 | +#include <boost/log/sources/record_ostream.hpp> |
645 | +#include <boost/log/support/date_time.hpp> |
646 | +#include <boost/log/utility/setup/console.hpp> |
647 | +#include <boost/log/utility/setup/file.hpp> |
648 | +#include <boost/log/utility/setup/common_attributes.hpp> |
649 | + |
650 | +#include <ubuntu/download_manager/download_struct.h> |
651 | +#include <ubuntu/download_manager/logging/logger.h> |
652 | + |
653 | +typedef boost::log::sources::severity_channel_logger_mt< |
654 | + Ubuntu::DownloadManager::Logging::Logger::Level, |
655 | + std::string> logger_mt; |
656 | + |
657 | +namespace { |
658 | + const std::string DOWNLOAD_MANAGER_CHANNEL = "ubuntu_download_manager"; |
659 | + void my_formatter(boost::log::record_view const& rec, |
660 | + boost::log::formatting_ostream& strm) { |
661 | + using namespace Ubuntu::DownloadManager::Logging; |
662 | + // grab the attributes we are interested in |
663 | + strm << boost::log::extract<unsigned int>("LineID", rec) << " ["; |
664 | + strm << boost::log::extract<boost::posix_time::ptime>("TimeStamp", rec) << "] "; |
665 | + strm << boost::log::extract<std::string>("Channel", rec) << " ["; |
666 | + auto severity = boost::log::extract<Logger::Level>("Severity", rec).get(); |
667 | + switch(severity) { |
668 | + case Logger::Debug: |
669 | + strm << "Debug"; |
670 | + break; |
671 | + case Logger::Normal: |
672 | + strm << "Normal"; |
673 | + break; |
674 | + case Logger::Notification: |
675 | + strm << "Notification"; |
676 | + break; |
677 | + case Logger::Warning: |
678 | + strm << "Warning"; |
679 | + break; |
680 | + case Logger::Error: |
681 | + strm << "Error"; |
682 | + break; |
683 | + default: |
684 | + strm << "Critical"; |
685 | + break; |
686 | + } |
687 | + strm << "] "; |
688 | + // Finally, put the record message to the stream |
689 | + strm << rec[boost::log::expressions::smessage]; |
690 | + } |
691 | +} |
692 | + |
693 | +namespace Ubuntu { |
694 | + |
695 | +namespace DownloadManager { |
696 | + |
697 | +namespace Logging { |
698 | + |
699 | +class LoggerPrivate { |
700 | + public: |
701 | + LoggerPrivate() { } |
702 | + |
703 | + void init(Logger::Level lvl, const QString& path) { |
704 | + if (_lg == nullptr) { |
705 | + boost::log::add_common_attributes(); |
706 | + |
707 | + _lg = new logger_mt( |
708 | + boost::log::keywords::channel = DOWNLOAD_MANAGER_CHANNEL, |
709 | + boost::log::keywords::severity = lvl); |
710 | + // create a sink with the given file name and then add a filter |
711 | + // to ensure that just the download manager logs are written in it |
712 | + auto sink = boost::log::add_file_log( |
713 | + boost::log::keywords::file_name = path.toStdString(), |
714 | + boost::log::keywords::auto_flush = true |
715 | + ); |
716 | + |
717 | + sink->set_formatter(&my_formatter); |
718 | + |
719 | + sink->set_filter |
720 | + ( |
721 | + boost::log::expressions::attr<std::string>("Channel") == DOWNLOAD_MANAGER_CHANNEL |
722 | + ); |
723 | + |
724 | + } else { |
725 | + log(Logger::Critical, "Logger init called more than once."); |
726 | + } |
727 | + } |
728 | + |
729 | + void log(Logger::Level lvl, const QString& msg) { |
730 | + if (_lg != nullptr) { |
731 | + auto rec = _lg->open_record(boost::log::keywords::severity = lvl); |
732 | + if (rec) { |
733 | + boost::log::record_ostream strm(rec); |
734 | + strm << msg.toStdString(); |
735 | + strm.flush(); |
736 | + _lg->push_record(boost::move(rec)); |
737 | + } |
738 | + } |
739 | + } |
740 | + |
741 | + void log(Logger::Level lvl, const QStringList& msgList) { |
742 | + auto msg = msgList.join(" "); |
743 | + log(lvl, msg); |
744 | + } |
745 | + |
746 | + void log(Logger::Level lvl, const QString& msg, QMap<QString, QString> map) { |
747 | + auto fmtMsg = msg.arg(toString(map)); |
748 | + log(lvl, fmtMsg); |
749 | + } |
750 | + |
751 | + void log(Logger::Level lvl, const QString& msg, DownloadStruct downStruct) { |
752 | + QStringList list; |
753 | + |
754 | + list << "\n\t\tUrl: " << downStruct.getUrl() |
755 | + << "\n\t\tHash Algorithm: '" << downStruct.getAlgorithm() << "'" |
756 | + << "\n\t\tMetadata: " << toString(downStruct.getMetadata()) |
757 | + << "\n\t\tHeaders: " << toString(downStruct.getHeaders()); |
758 | + |
759 | + auto fmtMsg = msg.arg(list.join("")); |
760 | + log(lvl, fmtMsg); |
761 | + } |
762 | + |
763 | + private: |
764 | + QString toString(QMap<QString, QString> map) { |
765 | + QStringList list; |
766 | + list << "{"; |
767 | + int index = map.keys().count(); |
768 | + foreach(const QString& key, map.keys()) { |
769 | + list << "'" << key << "': '" << map[key] << "'"; |
770 | + if (index != 1) { |
771 | + list << ", "; |
772 | + } |
773 | + index--; |
774 | + } |
775 | + list << "}"; |
776 | + return list.join(""); |
777 | + } |
778 | + |
779 | + QString toString(QVariantMap map) { |
780 | + QStringList list; |
781 | + list << "{"; |
782 | + int index = map.keys().count(); |
783 | + foreach(const QString& key, map.keys()) { |
784 | + list << "'" << key << "': '" |
785 | + << map[key].toString() << "'"; |
786 | + if (index != 1) { |
787 | + list << ", "; |
788 | + } |
789 | + index--; |
790 | + } |
791 | + list << "}"; |
792 | + return list.join(""); |
793 | + } |
794 | + |
795 | + private: |
796 | + logger_mt* _lg = nullptr; |
797 | +}; |
798 | + |
799 | +LoggerPrivate* Logger::_private = new LoggerPrivate(); |
800 | +QMutex Logger::_mutex; |
801 | + |
802 | +void |
803 | +Logger::init(Logger::Level lvl, const QString& path) { |
804 | + _mutex.lock(); |
805 | + _private->init(lvl, path); |
806 | + _mutex.unlock(); |
807 | +} |
808 | + |
809 | +void |
810 | +Logger::log(Logger::Level lvl, const QString& msg) { |
811 | + _private->log(lvl, msg); |
812 | +} |
813 | + |
814 | +void |
815 | +Logger::log(Logger::Level lvl, const QStringList& msg) { |
816 | + _private->log(lvl, msg); |
817 | +} |
818 | + |
819 | +void |
820 | +Logger::log(Level lvl, const QString& msg, QMap<QString, QString> map) { |
821 | + _private->log(lvl, msg, map); |
822 | +} |
823 | + |
824 | +void |
825 | +Logger::log(Level lvl, const QString& msg, DownloadStruct downStruct) { |
826 | + _private->log(lvl, msg, downStruct); |
827 | +} |
828 | + |
829 | +} // logging |
830 | + |
831 | +} // Transfers |
832 | + |
833 | +} // Ubuntu |
834 | |
835 | === added file 'src/downloads/client/ubuntu/download_manager/logging/logger.h' |
836 | --- src/downloads/client/ubuntu/download_manager/logging/logger.h 1970-01-01 00:00:00 +0000 |
837 | +++ src/downloads/client/ubuntu/download_manager/logging/logger.h 2014-07-03 10:39:06 +0000 |
838 | @@ -0,0 +1,106 @@ |
839 | +/* |
840 | + * Copyright 2014 Canonical Ltd. |
841 | + * |
842 | + * This library is free software; you can redistribute it and/or |
843 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
844 | + * License as published by the Free Software Foundation. |
845 | + * |
846 | + * This program is distributed in the hope that it will be useful, |
847 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
848 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
849 | + * General Public License for more details. |
850 | + * |
851 | + * You should have received a copy of the GNU Lesser General Public |
852 | + * License along with this library; if not, write to the |
853 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
854 | + * Boston, MA 02110-1301, USA. |
855 | + */ |
856 | + |
857 | +#ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_LOGGER_H |
858 | +#define UBUNTU_DOWNLOADMANAGER_CLIENT_LOGGER_H |
859 | + |
860 | +#include <QMap> |
861 | +#include <QMutex> |
862 | +#include <QString> |
863 | +#include <QStringList> |
864 | +#include <QVariant> |
865 | + |
866 | + |
867 | +namespace Ubuntu { |
868 | + |
869 | +namespace DownloadManager { |
870 | + |
871 | +class DownloadImpl; |
872 | +class DownloadPCW; |
873 | +class ManagerImpl; |
874 | +class DownloadManagerPCW; |
875 | +class DownloadsListManagerPCW; |
876 | +class GroupManagerPCW; |
877 | +class MetadataDownloadsListManagerPCW; |
878 | +class DownloadStruct; |
879 | + |
880 | +namespace Logging { |
881 | + |
882 | +class LoggerPrivate; |
883 | + |
884 | +/*! |
885 | + \class Logger |
886 | + \brief The Logger class allows to control a logging that |
887 | + is performed within the library allowed the developer |
888 | + to set the log level as well as the path of the file |
889 | + where the logs are written. |
890 | + \since 0.5 |
891 | + |
892 | +*/ |
893 | +class Logger { |
894 | + friend class Ubuntu::DownloadManager::DownloadImpl; |
895 | + friend class Ubuntu::DownloadManager::DownloadPCW; |
896 | + friend class Ubuntu::DownloadManager::ManagerImpl; |
897 | + friend class Ubuntu::DownloadManager::DownloadManagerPCW; |
898 | + friend class Ubuntu::DownloadManager::DownloadsListManagerPCW; |
899 | + friend class Ubuntu::DownloadManager::GroupManagerPCW; |
900 | + friend class Ubuntu::DownloadManager::MetadataDownloadsListManagerPCW; |
901 | + |
902 | + public: |
903 | + /*! The different log levels supported by the default logger of the lib. */ |
904 | + enum Level |
905 | + { |
906 | + Debug, |
907 | + Normal, |
908 | + Notification, |
909 | + Warning, |
910 | + Error, |
911 | + Critical |
912 | + }; |
913 | + |
914 | + /*! |
915 | + \fn static void Logger::init(Level lvl, const QString& path) |
916 | + |
917 | + Initializes the logging service for the download library using |
918 | + the given \a level and writing the logs to the given \a path. |
919 | + */ |
920 | + static void init(Level lvl, const QString& path); |
921 | + |
922 | + protected: |
923 | + |
924 | + /*! \cond PRIVATE |
925 | + */ |
926 | + static void log(Level lvl, const QString& msg); |
927 | + static void log(Level lvl, const QStringList& msg); |
928 | + static void log(Level lvl, const QString& msg, QMap<QString, QString> map); |
929 | + static void log(Level lvl, const QString& msg, DownloadStruct downStruct); |
930 | + /*! \endcond |
931 | + */ |
932 | + |
933 | + private: |
934 | + static QMutex _mutex; |
935 | + static LoggerPrivate* _private; |
936 | +}; |
937 | + |
938 | +} // Logging |
939 | + |
940 | +} // DownloadManager |
941 | + |
942 | +} // Ubuntu |
943 | + |
944 | +#endif |
945 | |
946 | === modified file 'src/downloads/client/ubuntu/download_manager/manager.cpp' |
947 | --- src/downloads/client/ubuntu/download_manager/manager.cpp 2014-02-12 12:01:11 +0000 |
948 | +++ src/downloads/client/ubuntu/download_manager/manager.cpp 2014-07-03 10:39:06 +0000 |
949 | @@ -16,9 +16,8 @@ |
950 | * Boston, MA 02110-1301, USA. |
951 | */ |
952 | |
953 | -#include <QDebug> |
954 | -#include "manager_impl.h" |
955 | -#include "manager.h" |
956 | +#include <ubuntu/download_manager/manager_impl.h> |
957 | +#include <ubuntu/download_manager/manager.h> |
958 | |
959 | namespace { |
960 | const QString DOWNLOAD_SERVICE = "com.canonical.applications.Downloader"; |
961 | |
962 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_impl.cpp' |
963 | --- src/downloads/client/ubuntu/download_manager/manager_impl.cpp 2014-04-09 11:10:26 +0000 |
964 | +++ src/downloads/client/ubuntu/download_manager/manager_impl.cpp 2014-07-03 10:39:06 +0000 |
965 | @@ -16,12 +16,13 @@ |
966 | * Boston, MA 02110-1301, USA. |
967 | */ |
968 | |
969 | -#include <QDebug> |
970 | -#include <glog/logging.h> |
971 | -#include "download_impl.h" |
972 | -#include "downloads_list.h" |
973 | +#include <ubuntu/download_manager/download_impl.h> |
974 | +#include <ubuntu/download_manager/downloads_list.h> |
975 | +#include <ubuntu/download_manager/logging/logger.h> |
976 | + |
977 | #include "manager_impl.h" |
978 | |
979 | + |
980 | namespace { |
981 | const QString MANAGER_PATH = "/"; |
982 | } |
983 | @@ -30,6 +31,8 @@ |
984 | |
985 | namespace DownloadManager { |
986 | |
987 | +using namespace Logging; |
988 | + |
989 | ManagerImpl::ManagerImpl(const QDBusConnection& conn, |
990 | const QString& path, |
991 | QObject* parent) |
992 | @@ -80,12 +83,14 @@ |
993 | |
994 | Download* |
995 | ManagerImpl::getDownloadForId(const QString& id) { |
996 | + Logger::log(Logger::Debug, QString("Manager getDownloadForId(%1)").arg(id)); |
997 | auto down = new DownloadImpl(_conn, _servicePath, QDBusObjectPath(id)); |
998 | return down; |
999 | } |
1000 | |
1001 | void |
1002 | ManagerImpl::createDownload(DownloadStruct downStruct) { |
1003 | + Logger::log(Logger::Debug, "Manager createDownload(%1)", downStruct); |
1004 | DownloadCb cb = [](Download*) {}; |
1005 | createDownload(downStruct, cb, cb); |
1006 | } |
1007 | @@ -98,8 +103,12 @@ |
1008 | _dbusInterface->createDownload(downStruct); |
1009 | auto watcher = new DownloadManagerPCW(_conn, |
1010 | _servicePath, call, cb, errCb, this); |
1011 | - CHECK(connect(watcher, &DownloadManagerPCW::callbackExecuted, |
1012 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
1013 | + auto connected = connect(watcher, &DownloadManagerPCW::callbackExecuted, |
1014 | + this, &ManagerImpl::onWatcherDone); |
1015 | + if (!connected) { |
1016 | + Logger::log(Logger::Critical, |
1017 | + "Could not connect to signal &DownloadManagerPCW::callbackExecuted,"); |
1018 | + } |
1019 | } |
1020 | |
1021 | void |
1022 | @@ -125,28 +134,40 @@ |
1023 | algorithm, allowed3G, metadata, headers); |
1024 | auto watcher = new GroupManagerPCW(_conn, _servicePath, |
1025 | call, cb, errCb, this); |
1026 | - CHECK(connect(watcher, &GroupManagerPCW::callbackExecuted, |
1027 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
1028 | + auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, |
1029 | + this, &ManagerImpl::onWatcherDone); |
1030 | + if (!connected) { |
1031 | + Logger::log(Logger::Critical, |
1032 | + "Could not connect to signal &GroupManagerPCW::callbackExecuted"); |
1033 | + } |
1034 | } |
1035 | |
1036 | void |
1037 | ManagerImpl::getAllDownloads() { |
1038 | + Logger::log(Logger::Debug, "Manager getAllDownloads()"); |
1039 | DownloadsListCb cb = [](DownloadsList*){}; |
1040 | getAllDownloads(cb, cb); |
1041 | } |
1042 | |
1043 | void |
1044 | ManagerImpl::getAllDownloads(DownloadsListCb cb, DownloadsListCb errCb) { |
1045 | + Logger::log(Logger::Debug, "Manager getAllDownloads()"); |
1046 | QDBusPendingCall call = _dbusInterface->getAllDownloads(); |
1047 | auto watcher = new DownloadsListManagerPCW( |
1048 | _conn, _servicePath, call, cb, errCb, this); |
1049 | - CHECK(connect(watcher, &GroupManagerPCW::callbackExecuted, |
1050 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
1051 | + auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, |
1052 | + this, &ManagerImpl::onWatcherDone); |
1053 | + if (!connected) { |
1054 | + Logger::log(Logger::Critical, |
1055 | + "Could not connect to signal"); |
1056 | + } |
1057 | } |
1058 | |
1059 | void |
1060 | ManagerImpl::getAllDownloadsWithMetadata(const QString &name, |
1061 | const QString &value) { |
1062 | + Logger::log(Logger::Debug, |
1063 | + QString("Manager getAllDownloadsWithMetadata(%1, %2)").arg(name).arg(value)); |
1064 | MetadataDownloadsListCb cb = |
1065 | [](const QString&, const QString&, DownloadsList*){}; |
1066 | getAllDownloadsWithMetadata(name, value, cb, cb); |
1067 | @@ -157,12 +178,17 @@ |
1068 | const QString &value, |
1069 | MetadataDownloadsListCb cb, |
1070 | MetadataDownloadsListCb errCb) { |
1071 | + Logger::log(Logger::Debug, |
1072 | + QString("Manager getAllDownloadsWithMetadata(%1, %2)").arg(name).arg(value)); |
1073 | QDBusPendingCall call = _dbusInterface->getAllDownloadsWithMetadata( |
1074 | name, value); |
1075 | auto watcher = new MetadataDownloadsListManagerPCW( |
1076 | _conn, _servicePath, call, name, value, cb, errCb, this); |
1077 | - CHECK(connect(watcher, &GroupManagerPCW::callbackExecuted, |
1078 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
1079 | + auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, |
1080 | + this, &ManagerImpl::onWatcherDone); |
1081 | + if (!connected) { |
1082 | + Logger::log(Logger::Critical, "Could not connect to signal"); |
1083 | + } |
1084 | } |
1085 | |
1086 | bool |
1087 | @@ -187,27 +213,29 @@ |
1088 | |
1089 | void |
1090 | ManagerImpl::allowMobileDataDownload(bool allowed) { |
1091 | + Logger::log(Logger::Debug, |
1092 | + QString("Manager allowMobileDataDownload(%1)").arg(allowed)); |
1093 | QDBusPendingReply<> reply = |
1094 | _dbusInterface->allowGSMDownload(allowed); |
1095 | // we block but because we expect it to be fast |
1096 | reply.waitForFinished(); |
1097 | if (reply.isError()) { |
1098 | auto err = reply.error(); |
1099 | - qCritical() << "Error setting mobile data" << err; |
1100 | + Logger::log(Logger::Critical, "Error setting mobile data"); |
1101 | setLastError(err); |
1102 | } |
1103 | } |
1104 | |
1105 | bool |
1106 | ManagerImpl::isMobileDataDownload() { |
1107 | + Logger::log(Logger::Debug, "Manager isMobileDataDownload()"); |
1108 | QDBusPendingReply<bool> reply = |
1109 | _dbusInterface->isGSMDownloadAllowed(); |
1110 | // we block but because we expect it to be fast |
1111 | reply.waitForFinished(); |
1112 | if (reply.isError()) { |
1113 | auto err = reply.error(); |
1114 | - qCritical() << "Error getting if mobile data is enabled" |
1115 | - << err; |
1116 | + Logger::log(Logger::Error, "Error getting if mobile data is enabled"); |
1117 | setLastError(err); |
1118 | return false; |
1119 | } else { |
1120 | @@ -217,13 +245,14 @@ |
1121 | |
1122 | qulonglong |
1123 | ManagerImpl::defaultThrottle() { |
1124 | + Logger::log(Logger::Debug, "Manager defaultThrottle()"); |
1125 | QDBusPendingReply<qulonglong> reply = |
1126 | _dbusInterface->defaultThrottle(); |
1127 | // we block but because we expect it to be fast |
1128 | reply.waitForFinished(); |
1129 | if (reply.isError()) { |
1130 | auto err = reply.error(); |
1131 | - qCritical() << "Error getting the default throttle" << err; |
1132 | + Logger::log(Logger::Error, "Error getting the default throttle"); |
1133 | setLastError(err); |
1134 | return 0; |
1135 | } else { |
1136 | @@ -233,26 +262,29 @@ |
1137 | |
1138 | void |
1139 | ManagerImpl::setDefaultThrottle(qulonglong speed) { |
1140 | + Logger::log(Logger::Debug, |
1141 | + QString("Manager setDefaultThrottle(%1)").arg(speed)); |
1142 | QDBusPendingReply<> reply = |
1143 | _dbusInterface->setDefaultThrottle(speed); |
1144 | // we block but because we expect it to be fast |
1145 | reply.waitForFinished(); |
1146 | if (reply.isError()) { |
1147 | auto err = reply.error(); |
1148 | - qCritical() << "Error setting default throttle" << err; |
1149 | + Logger::log(Logger::Error, "Error setting default throttle"); |
1150 | setLastError(err); |
1151 | } |
1152 | } |
1153 | |
1154 | void |
1155 | ManagerImpl::exit() { |
1156 | + Logger::log(Logger::Debug, "Manager exit()"); |
1157 | QDBusPendingReply<> reply = |
1158 | _dbusInterface->exit(); |
1159 | // we block but because we expect it to be fast |
1160 | reply.waitForFinished(); |
1161 | if (reply.isError()) { |
1162 | auto err = reply.error(); |
1163 | - qCritical() << "Error setting killing the daemon" << err; |
1164 | + Logger::log(Logger::Error, "Error setting killing the daemon"); |
1165 | setLastError(err); |
1166 | } |
1167 | } |
1168 | |
1169 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_impl.h' |
1170 | --- src/downloads/client/ubuntu/download_manager/manager_impl.h 2014-06-06 10:05:15 +0000 |
1171 | +++ src/downloads/client/ubuntu/download_manager/manager_impl.h 2014-07-03 10:39:06 +0000 |
1172 | @@ -21,13 +21,16 @@ |
1173 | |
1174 | #include <QDBusConnection> |
1175 | #include <QDBusObjectPath> |
1176 | + |
1177 | #include <ubuntu/transfers/visibility.h> |
1178 | #include <ubuntu/transfers/system/dbus_connection.h> |
1179 | -#include "download.h" |
1180 | -#include "error.h" |
1181 | -#include "group_download.h" |
1182 | -#include "manager_interface.h" |
1183 | -#include "manager_pendingcall_watcher.h" |
1184 | + |
1185 | +#include <ubuntu/download_manager/download.h> |
1186 | +#include <ubuntu/download_manager/error.h> |
1187 | +#include <ubuntu/download_manager/group_download.h> |
1188 | +#include <ubuntu/download_manager/manager_interface.h> |
1189 | +#include <ubuntu/download_manager/manager_pendingcall_watcher.h> |
1190 | + |
1191 | #include "manager.h" |
1192 | |
1193 | |
1194 | @@ -108,7 +111,6 @@ |
1195 | QString _servicePath; |
1196 | Error* _lastError = nullptr; |
1197 | ManagerInterface* _dbusInterface = nullptr; |
1198 | - |
1199 | }; |
1200 | |
1201 | } // DownloadManager |
1202 | |
1203 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp' |
1204 | --- src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp 2014-04-09 11:10:26 +0000 |
1205 | +++ src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp 2014-07-03 10:39:06 +0000 |
1206 | @@ -16,21 +16,27 @@ |
1207 | * Boston, MA 02110-1301, USA. |
1208 | */ |
1209 | |
1210 | -#include <QDebug> |
1211 | #include <QDBusPendingReply> |
1212 | #include <QDBusObjectPath> |
1213 | -#include <glog/logging.h> |
1214 | -#include "download_impl.h" |
1215 | -#include "downloads_list_impl.h" |
1216 | -#include "error.h" |
1217 | -#include "group_download.h" |
1218 | -#include "manager.h" |
1219 | -#include "manager_pendingcall_watcher.h" |
1220 | + |
1221 | +#include <boost/log/sources/record_ostream.hpp> |
1222 | +#include <boost/log/sources/severity_feature.hpp> |
1223 | + |
1224 | +#include <ubuntu/download_manager/download_impl.h> |
1225 | +#include <ubuntu/download_manager/downloads_list_impl.h> |
1226 | +#include <ubuntu/download_manager/error.h> |
1227 | +#include <ubuntu/download_manager/group_download.h> |
1228 | +#include <ubuntu/download_manager/manager.h> |
1229 | +#include <ubuntu/download_manager/logging/logger.h> |
1230 | + |
1231 | +#include <ubuntu/download_manager/manager_pendingcall_watcher.h> |
1232 | |
1233 | namespace Ubuntu { |
1234 | |
1235 | namespace DownloadManager { |
1236 | |
1237 | +using namespace Logging; |
1238 | + |
1239 | DownloadManagerPCW::DownloadManagerPCW(const QDBusConnection& conn, |
1240 | const QString& servicePath, |
1241 | const QDBusPendingCall& call, |
1242 | @@ -40,9 +46,12 @@ |
1243 | : PendingCallWatcher(conn, servicePath, call, parent), |
1244 | _cb(cb), |
1245 | _errCb(errCb) { |
1246 | - CHECK(connect(this, &QDBusPendingCallWatcher::finished, |
1247 | - this, &DownloadManagerPCW::onFinished)) |
1248 | - << "Could not connect to signal"; |
1249 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1250 | + this, &DownloadManagerPCW::onFinished); |
1251 | + if (!connected) { |
1252 | + Logger::log(Logger::Critical, |
1253 | + "Could not connect to signal &QDBusPendingCallWatcher::finished"); |
1254 | + } |
1255 | } |
1256 | |
1257 | void |
1258 | @@ -50,14 +59,14 @@ |
1259 | QDBusPendingReply<QDBusObjectPath> reply = *watcher; |
1260 | auto man = static_cast<Manager*>(parent()); |
1261 | if (reply.isError()) { |
1262 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
1263 | - // create error and deal with it |
1264 | + auto dbusErr = reply.error(); |
1265 | + Logger::log(Logger::Error, |
1266 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1267 | auto err = new DBusError(reply.error()); |
1268 | auto down = new DownloadImpl(_conn, err); |
1269 | _errCb(down); |
1270 | emit man->downloadCreated(down); |
1271 | } else { |
1272 | - qDebug() << "Success!"; |
1273 | auto path = reply.value(); |
1274 | auto down = new DownloadImpl(_conn, _servicePath, path); |
1275 | emit man->downloadCreated(down); |
1276 | @@ -76,8 +85,12 @@ |
1277 | : PendingCallWatcher(conn, servicePath, call, parent), |
1278 | _cb(cb), |
1279 | _errCb(errCb) { |
1280 | - connect(this, &QDBusPendingCallWatcher::finished, |
1281 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1282 | this, &DownloadsListManagerPCW::onFinished); |
1283 | + if (!connected) { |
1284 | + Logger::log(Logger::Critical, |
1285 | + "Could not connect to signal &QDBusPendingCallWatcher::finished"); |
1286 | + } |
1287 | } |
1288 | |
1289 | void |
1290 | @@ -86,14 +99,14 @@ |
1291 | DownloadsListImpl* list; |
1292 | auto man = static_cast<Manager*>(parent()); |
1293 | if (reply.isError()) { |
1294 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
1295 | - // create error and deal with it |
1296 | + auto dbusErr = reply.error(); |
1297 | + Logger::log(Logger::Error, |
1298 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1299 | auto err = new DBusError(reply.error()); |
1300 | list = new DownloadsListImpl(err); |
1301 | _errCb(list); |
1302 | emit man->downloadsFound(list); |
1303 | } else { |
1304 | - qDebug() << "Success!"; |
1305 | auto paths = reply.value(); |
1306 | QList<QSharedPointer<Download> > downloads; |
1307 | list = new DownloadsListImpl(); |
1308 | @@ -125,8 +138,12 @@ |
1309 | _value(value), |
1310 | _cb(cb), |
1311 | _errCb(errCb) { |
1312 | - connect(this, &QDBusPendingCallWatcher::finished, |
1313 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1314 | this, &MetadataDownloadsListManagerPCW::onFinished); |
1315 | + if (!connected) { |
1316 | + Logger::log(Logger::Critical, |
1317 | + "Could not connect to signal &QDBusPendingCallWatcher::finished"); |
1318 | + } |
1319 | } |
1320 | |
1321 | void |
1322 | @@ -135,14 +152,14 @@ |
1323 | DownloadsListImpl* list; |
1324 | auto man = static_cast<Manager*>(parent()); |
1325 | if (reply.isError()) { |
1326 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
1327 | - // create error and deal with it |
1328 | + auto dbusErr = reply.error(); |
1329 | + Logger::log(Logger::Error, |
1330 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1331 | auto err = new DBusError(reply.error()); |
1332 | list = new DownloadsListImpl(err); |
1333 | _errCb(_key, _value, list); |
1334 | emit man->downloadsWithMetadataFound(_key, _value, list); |
1335 | } else { |
1336 | - qDebug() << "Success!"; |
1337 | auto paths = reply.value(); |
1338 | QList<QSharedPointer<Download> > downloads; |
1339 | list = new DownloadsListImpl(); |
1340 | @@ -169,9 +186,12 @@ |
1341 | : PendingCallWatcher(conn, servicePath, call, parent), |
1342 | _cb(cb), |
1343 | _errCb(errCb) { |
1344 | - CHECK(connect(this, &QDBusPendingCallWatcher::finished, |
1345 | - this, &GroupManagerPCW::onFinished)) |
1346 | - << "Could not connect to signal"; |
1347 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1348 | + this, &GroupManagerPCW::onFinished); |
1349 | + if (!connected) { |
1350 | + Logger::log(Logger::Critical, |
1351 | + "Could not connect to signal &DownloadPCW::finished"); |
1352 | + } |
1353 | } |
1354 | |
1355 | void |
1356 | @@ -179,7 +199,9 @@ |
1357 | QDBusPendingReply<QDBusObjectPath> reply = *watcher; |
1358 | auto man = static_cast<Manager*>(parent()); |
1359 | if (reply.isError()) { |
1360 | - // creater error and deal with it |
1361 | + auto dbusErr = reply.error(); |
1362 | + Logger::log(Logger::Error, |
1363 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1364 | auto err = new DBusError(reply.error()); |
1365 | auto down = new GroupDownload(err); |
1366 | _errCb(down); |
1367 | |
1368 | === modified file 'tests/local_tree_testcase.cpp' |
1369 | --- tests/local_tree_testcase.cpp 2014-03-27 12:54:03 +0000 |
1370 | +++ tests/local_tree_testcase.cpp 2014-07-03 10:39:06 +0000 |
1371 | @@ -48,4 +48,6 @@ |
1372 | |
1373 | QString smallFile = dataDirectory() + "/" + QString(SMALL_FILE); |
1374 | addFileToHttpServer(smallFile); |
1375 | + Ubuntu::DownloadManager::Logging::Logger::init( |
1376 | + Ubuntu::DownloadManager::Logging::Logger::Debug, testDirectory() + "/client.log"); |
1377 | } |
1378 | |
1379 | === modified file 'tests/local_tree_testcase.h' |
1380 | --- tests/local_tree_testcase.h 2014-03-12 12:59:51 +0000 |
1381 | +++ tests/local_tree_testcase.h 2014-07-03 10:39:06 +0000 |
1382 | @@ -21,6 +21,8 @@ |
1383 | |
1384 | #include <QObject> |
1385 | #include <QUrl> |
1386 | + |
1387 | +#include <ubuntu/download_manager/logging/logger.h> |
1388 | #include "daemon_testcase.h" |
1389 | |
1390 | class LocalTreeTestCase : public DaemonTestCase { |
PASSED: Continuous integration, rev:323 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- ci/684/ jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- utopic- amd64-ci/ 43 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- utopic- armhf-ci/ 43 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- utopic- armhf-ci/ 43/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- download- manager- ci/684/ rebuild
http://