Mir

Merge lp:~alan-griffiths/mir/add-glog-logging into lp:~mir-team/mir/trunk

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 546
Proposed branch: lp:~alan-griffiths/mir/add-glog-logging
Merge into: lp:~mir-team/mir/trunk
Diff against target: 344 lines (+166/-17)
13 files modified
CMakeLists.txt (+1/-0)
cmake/FindGLog.cmake (+14/-0)
cmake/FindLibHardware.cmake (+2/-1)
cmake/LinuxCrossCompile.cmake (+0/-5)
include/server/mir/logging/glog_logger.h (+41/-0)
include/server/mir/logging/logger.h (+1/-2)
src/server/CMakeLists.txt (+4/-0)
src/server/default_server_configuration.cpp (+38/-9)
src/server/logging/CMakeLists.txt (+1/-0)
src/server/logging/glog_logger.cpp (+55/-0)
tests/unit-tests/graphics/gbm/test_gbm_display.cpp (+2/-0)
tests/unit-tests/logging/message_processor_report.cpp (+1/-0)
tools/setup-partial-armhf-chroot.sh (+6/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/add-glog-logging
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Approve
Alan Griffiths Pending
Review via email: mp+153568@code.launchpad.net

This proposal supersedes a proposal from 2013-03-04.

Commit message

logging, config: Add a glog based logging option

Description of the change

logging, config: Add a glog based logging option

Resubmitted after getting glog through MIR [MainInclusionProcess]

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
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal

we have to find an armhf package we can use before this lands. I don't seem to find an armhf package in:
"deb http://ports.ubuntu.com/ubuntu-ports/ quantal main restricted universe multiverse" (the sources.list line in the phone image)

could this be what we're waiting for?
https://launchpad.net/ubuntu/+source/google-glog

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

glog is in universe. We should be using a loggong package that's in main

review: Disapprove
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> glog is in universe. We should be using a loggong package that's in main

There is no logging package in main. Have raised a MIR. Will resubmit when that's been addressed.

review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

i have to bump the android scripts and figure out why its not finding the glog library, i'll propose a branch to mp into this one about that. I'll block on myself with a 'needs fixing'

line 256/257, presumably we overload info because glog only has 4 levels?

line 98, is a bit chatty, for me, i see
...
-- Found GLog: /home/kdub/source/ndk-rewrite-glog/usr/lib/arm-linux-gnueabihf/libglog.so
-- Found LIBHARDWARE: /home/kdub/source/ndk-rewrite-glog/usr/lib/arm-linux-gnueabihf/libhardware.so.1
-- GLog_LIBRARY=/home/kdub/source/ndk-rewrite-glog/usr/lib/arm-linux-gnueabihf/libglog.so
...

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

the new dependency is now in raring, but not quantal. The phablet image at the moment is still quantal, so we'll either have to do an sru to update quantal, or install the raring package on the phablet device. I favor the 2nd (not that many more steps), so I'll update the scripts to do that

Revision history for this message
Kevin DuBois (kdub) wrote :

i updated our scripts and pulled the content of ndk-rewrite in here: lp:~mir-team/mir/consolidate-crossbuild-scripts (which has this glog dependency) I have to do some more testing on that branch and then explain the changes to the team.

Revision history for this message
Kevin DuBois (kdub) wrote :

sorry for the delay on that branch, will try to unblock this today!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

looking into it

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

looks good to me, sorry for the delay on the android dependency.

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

I guess that when we standardize on a single logging system, we could drop glog references from the command line options.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Failure looks like a glitch - reapproving

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-03-28 09:50:09 +0000
3+++ CMakeLists.txt 2013-03-29 10:46:21 +0000
4@@ -120,6 +120,7 @@
5 find_package(EGL REQUIRED)
6 find_package(GLESv2 REQUIRED)
7 find_package(Protobuf REQUIRED )
8+find_package(GLog REQUIRED)
9
10 include_directories (${GLESv2_INCLUDE_DIRS})
11 include_directories (${EGL_INCLUDE_DIRS})
12
13=== added file 'cmake/FindGLog.cmake'
14--- cmake/FindGLog.cmake 1970-01-01 00:00:00 +0000
15+++ cmake/FindGLog.cmake 2013-03-29 10:46:21 +0000
16@@ -0,0 +1,14 @@
17+if (GLog_INCLUDE_DIR)
18+ # Already in cache, be silent
19+ set(GLog_FIND_QUIETLY TRUE)
20+endif ()
21+
22+find_path(GLog_INCLUDE_DIR glog/logging.h)
23+
24+find_library(GLog_LIBRARY libglog.so
25+ HINTS /usr/lib/arm-linux-gnueabihf/)
26+
27+include(FindPackageHandleStandardArgs)
28+find_package_handle_standard_args(GLog DEFAULT_MSG GLog_LIBRARY GLog_INCLUDE_DIR)
29+
30+mark_as_advanced(GLog_LIBRARY GLog_INCLUDE_DIR)
31
32=== modified file 'cmake/FindLibHardware.cmake'
33--- cmake/FindLibHardware.cmake 2013-03-13 04:54:15 +0000
34+++ cmake/FindLibHardware.cmake 2013-03-29 10:46:21 +0000
35@@ -19,7 +19,8 @@
36 find_library(LIBHARDWARE_LIBRARY
37 NAMES libhardware.so.1
38 libhardware.so
39- )
40+ HINTS /usr/lib/arm-linux-gnueabihf/
41+)
42
43 set(LIBHARDWARE_LIBRARIES ${LIBHARDWARE_LIBRARY})
44 set(LIBHARDWARE_INCLUDE_DIRS ${LIBHARDWARE_INCLUDE_DIR})
45
46=== modified file 'cmake/LinuxCrossCompile.cmake'
47--- cmake/LinuxCrossCompile.cmake 2013-03-13 04:54:15 +0000
48+++ cmake/LinuxCrossCompile.cmake 2013-03-29 10:46:21 +0000
49@@ -15,11 +15,6 @@
50 include_directories(SYSTEM ${MIR_NDK_PATH}/usr/include)
51 list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${MIR_NDK_PATH}/usr/include")
52
53-#add directories from the chroot to search for libraries
54-link_directories(${MIR_NDK_PATH}/lib/
55- ${MIR_ARM_EABI}/usr/lib
56- ${MIR_NDK_PATH}/usr/lib/${MIR_ARM_EABI})
57-
58 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
59 set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
60 set(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,-rpath-link,")
61
62=== added file 'include/server/mir/logging/glog_logger.h'
63--- include/server/mir/logging/glog_logger.h 1970-01-01 00:00:00 +0000
64+++ include/server/mir/logging/glog_logger.h 2013-03-29 10:46:21 +0000
65@@ -0,0 +1,41 @@
66+/*
67+ * Copyright © 2013 Canonical Ltd.
68+ *
69+ * This program is free software: you can redistribute it and/or modify
70+ * it under the terms of the GNU General Public License version 3 as
71+ * published by the Free Software Foundation.
72+ *
73+ * This program is distributed in the hope that it will be useful,
74+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
75+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76+ * GNU General Public License for more details.
77+ *
78+ * You should have received a copy of the GNU General Public License
79+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
80+ *
81+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
82+ */
83+
84+#include "mir/logging/logger.h"
85+
86+namespace mir
87+{
88+namespace logging
89+{
90+class GlogLogger : public Logger
91+{
92+public:
93+ GlogLogger(
94+ char const* argv0,
95+ int stderrthreshold,
96+ int minloglevel,
97+ std::string const& log_dir);
98+
99+private:
100+ virtual void log(
101+ Severity severity,
102+ const std::string& message,
103+ const std::string& component);
104+};
105+}
106+}
107
108=== modified file 'include/server/mir/logging/logger.h'
109--- include/server/mir/logging/logger.h 2013-03-13 04:54:15 +0000
110+++ include/server/mir/logging/logger.h 2013-03-29 10:46:21 +0000
111@@ -39,8 +39,6 @@
112 debug = 4
113 };
114
115- virtual ~Logger() {}
116-
117 template<Severity severity>
118 void log(const std::string& message)
119 {
120@@ -56,6 +54,7 @@
121
122 protected:
123 Logger() {}
124+ virtual ~Logger() = default;
125 Logger(const Logger&) = delete;
126 Logger& operator=(const Logger&) = delete;
127
128
129=== modified file 'src/server/CMakeLists.txt'
130--- src/server/CMakeLists.txt 2013-03-28 12:13:18 +0000
131+++ src/server/CMakeLists.txt 2013-03-29 10:46:21 +0000
132@@ -20,6 +20,9 @@
133 ${CMAKE_CURRENT_BINARY_DIR}/mirserver.pc
134 )
135
136+MESSAGE(STATUS "GLog_LIBRARY=" ${GLog_LIBRARY})
137+MESSAGE(STATUS "GLog_LIBRARY=" ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
138+
139 set(
140 SRCS
141 run_mir.cpp
142@@ -57,6 +60,7 @@
143 mirprotobuf
144 3rd_party
145 ${Boost_LIBRARIES}
146+ ${GLog_LIBRARY}
147 )
148
149 if(${MIRSERVER_LINKAGE} STREQUAL SHARED)
150
151=== modified file 'src/server/default_server_configuration.cpp'
152--- src/server/default_server_configuration.cpp 2013-03-28 09:47:22 +0000
153+++ src/server/default_server_configuration.cpp 2013-03-29 10:46:21 +0000
154@@ -46,6 +46,7 @@
155 #include "mir/input/input_manager.h"
156 #include "mir/logging/logger.h"
157 #include "mir/logging/dumb_console_logger.h"
158+#include "mir/logging/glog_logger.h"
159 #include "mir/logging/session_mediator_report.h"
160 #include "mir/logging/message_processor_report.h"
161 #include "mir/logging/display_report.h"
162@@ -125,6 +126,11 @@
163 char const* const log_msg_processor = "log-msg-processor";
164 char const* const log_display = "log-display";
165
166+char const* const glog = "glog";
167+char const* const glog_stderrthreshold = "glog-stderrthreshold";
168+char const* const glog_minloglevel = "glog-minloglevel";
169+char const* const glog_log_dir = "glog-log-dir";
170+
171 boost::program_options::options_description program_options()
172 {
173 namespace po = boost::program_options;
174@@ -133,13 +139,26 @@
175 "Command-line options.\n"
176 "Environment variables capitalise long form with prefix \"MIR_SERVER_\" and \"_\" in place of \"-\"");
177 desc.add_options()
178- ("file,f", po::value<std::string>(), "socket filename")
179- ("ipc-thread-pool,i", po::value<int>(), "threads in frontend thread pool")
180- (log_display, po::value<bool>(), "log the Display report")
181- (log_app_mediator, po::value<bool>(), "log the ApplicationMediator report")
182+ ("file,f", po::value<std::string>(), "Socket filename")
183+ (log_display, po::value<bool>(), "Log the Display report. [bool:default=false]")
184+ (log_app_mediator, po::value<bool>(), "Log the ApplicationMediator report. [bool:default=false]")
185 (log_msg_processor, po::value<bool>(), "log the MessageProcessor report")
186- ("tests-use-real-graphics", po::value<bool>(), "use real graphics in tests")
187- ("tests-use-real-input", po::value<bool>(), "use real input in tests");
188+ (glog, "Use google::GLog for logging")
189+ (glog_stderrthreshold, po::value<int>(),"Copy log messages at or above this level "
190+ "to stderr in addition to logfiles. The numbers "
191+ "of severity levels INFO, WARNING, ERROR, and "
192+ "FATAL are 0, 1, 2, and 3, respectively."
193+ " [int:default=2]")
194+ (glog_minloglevel, po::value<int>(), "Log messages at or above this level. The numbers "
195+ "of severity levels INFO, WARNING, ERROR, and "
196+ "FATAL are 0, 1, 2, and 3, respectively."
197+ " [int:default=0]")
198+ (glog_log_dir, po::value<std::string>(),"If specified, logfiles are written into this "
199+ "directory instead of the default logging directory."
200+ " [string:default=\"\"]")
201+ ("ipc-thread-pool,i", po::value<int>(), "threads in frontend thread pool. [int:default=10]")
202+ ("tests-use-real-graphics", po::value<bool>(), "Use real graphics in tests. [bool:default=false]")
203+ ("tests-use-real-input", po::value<bool>(), "Use real input in tests. [bool:default=false]");
204
205 return desc;
206 }
207@@ -456,10 +475,20 @@
208 std::shared_ptr<ml::Logger> mir::DefaultServerConfiguration::the_logger()
209 {
210 return logger(
211- [this]()
212+ [this]() -> std::shared_ptr<ml::Logger>
213 {
214- // TODO use the_options() to configure logging
215- return std::make_shared<ml::DumbConsoleLogger>();
216+ if (the_options()->is_set(glog))
217+ {
218+ return std::make_shared<ml::GlogLogger>(
219+ "mir",
220+ the_options()->get(glog_stderrthreshold, 2),
221+ the_options()->get(glog_minloglevel, 0),
222+ the_options()->get(glog_log_dir, ""));
223+ }
224+ else
225+ {
226+ return std::make_shared<ml::DumbConsoleLogger>();
227+ }
228 });
229 }
230
231
232=== modified file 'src/server/logging/CMakeLists.txt'
233--- src/server/logging/CMakeLists.txt 2013-03-25 15:15:53 +0000
234+++ src/server/logging/CMakeLists.txt 2013-03-29 10:46:21 +0000
235@@ -2,6 +2,7 @@
236 LOGGING_SOURCES
237
238 dumb_console_logger.cpp
239+ glog_logger.cpp
240 session_mediator_report.cpp
241 message_processor_report.cpp
242 display_report.cpp
243
244=== added file 'src/server/logging/glog_logger.cpp'
245--- src/server/logging/glog_logger.cpp 1970-01-01 00:00:00 +0000
246+++ src/server/logging/glog_logger.cpp 2013-03-29 10:46:21 +0000
247@@ -0,0 +1,55 @@
248+/*
249+ * Copyright © 2013 Canonical Ltd.
250+ *
251+ * This program is free software: you can redistribute it and/or modify
252+ * it under the terms of the GNU General Public License version 3 as
253+ * published by the Free Software Foundation.
254+ *
255+ * This program is distributed in the hope that it will be useful,
256+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
257+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
258+ * GNU General Public License for more details.
259+ *
260+ * You should have received a copy of the GNU General Public License
261+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
262+ *
263+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
264+ */
265+
266+#include "mir/logging/glog_logger.h"
267+
268+#include <glog/logging.h>
269+
270+#include <mutex>
271+#include <cstdlib>
272+
273+mir::logging::GlogLogger::GlogLogger(
274+ const char* argv0,
275+ int stderrthreshold,
276+ int minloglevel,
277+ std::string const& log_dir)
278+{
279+ FLAGS_stderrthreshold = stderrthreshold;
280+ FLAGS_minloglevel = minloglevel;
281+ FLAGS_log_dir = log_dir;
282+
283+ static std::once_flag init_flag;
284+
285+ std::call_once(init_flag, [=]() { google::InitGoogleLogging(argv0); });
286+}
287+
288+void mir::logging::GlogLogger::log(Severity severity, const std::string& message, const std::string& component)
289+{
290+ static int glog_level[] =
291+ {
292+ google::GLOG_FATAL, // critical = 0,
293+ google::GLOG_ERROR, // error = 1,
294+ google::GLOG_WARNING, // warning = 2,
295+ google::GLOG_INFO, // informational = 3,
296+ google::GLOG_INFO, // debug = 4
297+ };
298+
299+ // Since we're not collecting __FILE__ or __LINE__ this is misleading
300+ google::LogMessage(__FILE__, __LINE__, glog_level[severity]).stream()
301+ << '[' << component << "] " << message;
302+}
303
304=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_display.cpp'
305--- tests/unit-tests/graphics/gbm/test_gbm_display.cpp 2013-03-13 08:09:52 +0000
306+++ tests/unit-tests/graphics/gbm/test_gbm_display.cpp 2013-03-29 10:46:21 +0000
307@@ -44,6 +44,8 @@
308 {
309 MOCK_METHOD3(log,
310 void(ml::Logger::Severity, const std::string&, const std::string&));
311+
312+ ~MockLogger() noexcept(true) {}
313 };
314
315 class GBMDisplayTest : public ::testing::Test
316
317=== modified file 'tests/unit-tests/logging/message_processor_report.cpp'
318--- tests/unit-tests/logging/message_processor_report.cpp 2013-03-27 17:18:33 +0000
319+++ tests/unit-tests/logging/message_processor_report.cpp 2013-03-29 10:46:21 +0000
320@@ -40,6 +40,7 @@
321 {
322 public:
323 MOCK_METHOD3(log, void(Severity severity, const std::string& message, const std::string& component));
324+ ~MockLogger() noexcept(true) {}
325 };
326
327 struct MessageProcessorReport : public Test
328
329=== modified file 'tools/setup-partial-armhf-chroot.sh'
330--- tools/setup-partial-armhf-chroot.sh 2013-03-26 15:55:51 +0000
331+++ tools/setup-partial-armhf-chroot.sh 2013-03-29 10:46:21 +0000
332@@ -86,6 +86,12 @@
333 if [ ! -f libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb ]; then
334 wget "http://launchpadlibrarian.net/134086853/libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb"
335 fi
336+
337+ if [ ! -f libgflags-dev_2.0-1_armhf.deb ]; then
338+ wget "http://launchpadlibrarian.net/106868249/libgflags-dev_2.0-1_armhf.deb"
339+ fi
340+
341+ dpkg -x libgflags-dev_2.0-1_armhf.deb .
342 dpkg -x libgflags2_2.0-1_armhf.deb .
343 dpkg -x libgoogle-glog0_0.3.2-4ubuntu1_armhf.deb .
344 dpkg -x libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb .

Subscribers

People subscribed via source and target branches