Merge lp:~mandel/ubuntu-download-manager/expose-logger into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Needs review
Proposed branch: lp:~mandel/ubuntu-download-manager/expose-logger
Merge into: lp:ubuntu-download-manager
Prerequisite: lp:~mandel/ubuntu-download-manager/add-qml-tests
Diff against target: 194 lines (+143/-2)
5 files modified
docs/qml/pages/mainpage.qdoc (+1/-0)
src/downloads/qml/CMakeLists.txt (+2/-0)
src/downloads/qml/logger.cpp (+67/-0)
src/downloads/qml/logger.h (+53/-0)
src/downloads/qml/single_download.cpp (+20/-2)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/expose-logger
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+225685@code.launchpad.net

This proposal supersedes a proposal from 2014-06-30.

Commit message

Expose the logger object in the QML so that app developers can easily debug the download manager.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

337. By Manuel de la Peña

Merged with previous branch.

336. By Manuel de la Peña

Merged expose-property into expose-logger.

335. By Manuel de la Peña

Merged expose-property into expose-logger.

334. By Manuel de la Peña

Merged expose-property into expose-logger.

333. By Manuel de la Peña

Style.

332. By Manuel de la Peña

Improve docs.

331. By Manuel de la Peña

Update docs.

330. By Manuel de la Peña

Merged expose-property into expose-logger.

329. By Manuel de la Peña

Merged expose-property into expose-logger.

328. By Manuel de la Peña

Added missing logger files.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/qml/pages/mainpage.qdoc'
2--- docs/qml/pages/mainpage.qdoc 2014-06-20 10:10:50 +0000
3+++ docs/qml/pages/mainpage.qdoc 2014-07-04 15:24:39 +0000
4@@ -41,6 +41,7 @@
5 \list
6 \li \l {DownloadManager}
7 \li \l {SingleDownload}
8+ \li \l {Logger}
9 \endlist
10
11 \section1 Example usage - Downloading a file
12
13=== modified file 'src/downloads/qml/CMakeLists.txt'
14--- src/downloads/qml/CMakeLists.txt 2014-07-04 15:24:39 +0000
15+++ src/downloads/qml/CMakeLists.txt 2014-07-04 15:24:39 +0000
16@@ -4,6 +4,7 @@
17 set(plugin_SRCS
18 backend.cpp
19 download_error.cpp
20+ logger.cpp
21 single_download.cpp
22 ubuntu_download_manager.cpp
23 )
24@@ -11,6 +12,7 @@
25 set(plugin_HDRS
26 backend.h
27 download_error.h
28+ logger.h
29 single_download.h
30 ubuntu_download_manager.h
31 )
32
33=== added file 'src/downloads/qml/logger.cpp'
34--- src/downloads/qml/logger.cpp 1970-01-01 00:00:00 +0000
35+++ src/downloads/qml/logger.cpp 2014-07-04 15:24:39 +0000
36@@ -0,0 +1,67 @@
37+/*
38+ * Copyright 2014 Canonical Ltd.
39+ *
40+ * This library is free software; you can redistribute it and/or
41+ * modify it under the terms of version 3 of the GNU Lesser General Public
42+ * License as published by the Free Software Foundation.
43+ *
44+ * This program is distributed in the hope that it will be useful,
45+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
46+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47+ * General Public License for more details.
48+ *
49+ * You should have received a copy of the GNU Lesser General Public
50+ * License along with this library; if not, write to the
51+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
52+ * Boston, MA 02110-1301, USA.
53+ */
54+
55+#include <ubuntu/download_manager/logging/logger.h>
56+
57+#include "logger.h"
58+
59+namespace Ubuntu {
60+
61+namespace DownloadManager {
62+
63+/*!
64+ \qmltype Logger
65+ \instantiates Logger
66+ \inqmlmodule Ubuntu.DownloadManager 0.1
67+ \ingroup download
68+ \brief Allows to set the logging level used by the plugin.
69+
70+ The logger object allows to set the logging level that will be used
71+ by the plugin to allow better debugging. All logging performed by the
72+ library is thread safe and can be used to determine the different operations
73+ that are taken per download using the download id to indentify them.
74+*/
75+
76+Logger::Logger(QObject* parent)
77+ : QObject(parent) {
78+}
79+
80+/*!
81+ \qmlmethod void Logger::init(Logger::Level lvl, QString path)
82+
83+ Initializes the logging service of the plugin with the given level and will
84+ write the logs in the passed full path. If the path does not exist it will
85+ be created.
86+*/
87+void
88+Logger::init(Logger::Level lvl, QString path) {
89+ // cast the level to the logging level and init
90+ auto lgLvl = static_cast<Ubuntu::DownloadManager::Logging::Logger::Level>(lvl);
91+ Ubuntu::DownloadManager::Logging::Logger::init(lgLvl, path);
92+}
93+
94+/*!
95+ \enum Logger::Level
96+
97+ The level to be used when writing the logs.
98+*/
99+
100+} // DownloadManager
101+
102+} // Ubuntu
103+
104
105=== added file 'src/downloads/qml/logger.h'
106--- src/downloads/qml/logger.h 1970-01-01 00:00:00 +0000
107+++ src/downloads/qml/logger.h 2014-07-04 15:24:39 +0000
108@@ -0,0 +1,53 @@
109+/*
110+ * Copyright 2014 Canonical Ltd.
111+ *
112+ * This library is free software; you can redistribute it and/or
113+ * modify it under the terms of version 3 of the GNU Lesser General Public
114+ * License as published by the Free Software Foundation.
115+ *
116+ * This program is distributed in the hope that it will be useful,
117+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
118+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
119+ * General Public License for more details.
120+ *
121+ * You should have received a copy of the GNU Lesser General Public
122+ * License along with this library; if not, write to the
123+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
124+ * Boston, MA 02110-1301, USA.
125+ */
126+
127+#ifndef DOWNLOAD_QML_LOGGER_H
128+#define DOWNLOAD_QML_LOGGER_H
129+
130+namespace Ubuntu {
131+
132+namespace DownloadManager {
133+
134+class Logger : public QObject {
135+ Q_OBJECT
136+ Q_ENUMS(Level)
137+
138+ public:
139+
140+ enum Level {
141+ Debug,
142+ Normal,
143+ Notification,
144+ Warning,
145+ Error,
146+ Critical
147+ };
148+
149+ explicit Logger(QObject* parent=0);
150+
151+ Q_INVOKABLE void init(Level lvl, QString path);
152+
153+ private:
154+ QString m_path; // path used to log
155+};
156+
157+} // DownloadManager
158+
159+} // Ubuntu
160+
161+#endif // DOWNLOAD_QML_LOGGER_H
162
163=== modified file 'src/downloads/qml/single_download.cpp'
164--- src/downloads/qml/single_download.cpp 2014-07-04 15:24:39 +0000
165+++ src/downloads/qml/single_download.cpp 2014-07-04 15:24:39 +0000
166@@ -1,8 +1,26 @@
167-#include <QDebug>
168-#include "single_download.h"
169+/*
170+ * Copyright 2014 Canonical Ltd.
171+ *
172+ * This library is free software; you can redistribute it and/or
173+ * modify it under the terms of version 3 of the GNU Lesser General Public
174+ * License as published by the Free Software Foundation.
175+ *
176+ * This program is distributed in the hope that it will be useful,
177+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
178+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
179+ * General Public License for more details.
180+ *
181+ * You should have received a copy of the GNU Lesser General Public
182+ * License along with this library; if not, write to the
183+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
184+ * Boston, MA 02110-1301, USA.
185+ */
186+
187 #include <glog/logging.h>
188 #include <ubuntu/download_manager/download_struct.h>
189
190+#include "single_download.h"
191+
192 namespace Ubuntu {
193
194 namespace DownloadManager {

Subscribers

People subscribed via source and target branches