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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-03-28 09:50:09 +0000
+++ CMakeLists.txt 2013-03-29 10:46:21 +0000
@@ -120,6 +120,7 @@
120find_package(EGL REQUIRED)120find_package(EGL REQUIRED)
121find_package(GLESv2 REQUIRED)121find_package(GLESv2 REQUIRED)
122find_package(Protobuf REQUIRED )122find_package(Protobuf REQUIRED )
123find_package(GLog REQUIRED)
123124
124include_directories (${GLESv2_INCLUDE_DIRS}) 125include_directories (${GLESv2_INCLUDE_DIRS})
125include_directories (${EGL_INCLUDE_DIRS})126include_directories (${EGL_INCLUDE_DIRS})
126127
=== added file 'cmake/FindGLog.cmake'
--- cmake/FindGLog.cmake 1970-01-01 00:00:00 +0000
+++ cmake/FindGLog.cmake 2013-03-29 10:46:21 +0000
@@ -0,0 +1,14 @@
1if (GLog_INCLUDE_DIR)
2 # Already in cache, be silent
3 set(GLog_FIND_QUIETLY TRUE)
4endif ()
5
6find_path(GLog_INCLUDE_DIR glog/logging.h)
7
8find_library(GLog_LIBRARY libglog.so
9 HINTS /usr/lib/arm-linux-gnueabihf/)
10
11include(FindPackageHandleStandardArgs)
12find_package_handle_standard_args(GLog DEFAULT_MSG GLog_LIBRARY GLog_INCLUDE_DIR)
13
14mark_as_advanced(GLog_LIBRARY GLog_INCLUDE_DIR)
015
=== modified file 'cmake/FindLibHardware.cmake'
--- cmake/FindLibHardware.cmake 2013-03-13 04:54:15 +0000
+++ cmake/FindLibHardware.cmake 2013-03-29 10:46:21 +0000
@@ -19,7 +19,8 @@
19find_library(LIBHARDWARE_LIBRARY19find_library(LIBHARDWARE_LIBRARY
20 NAMES libhardware.so.1 20 NAMES libhardware.so.1
21 libhardware.so 21 libhardware.so
22 )22 HINTS /usr/lib/arm-linux-gnueabihf/
23)
2324
24set(LIBHARDWARE_LIBRARIES ${LIBHARDWARE_LIBRARY})25set(LIBHARDWARE_LIBRARIES ${LIBHARDWARE_LIBRARY})
25set(LIBHARDWARE_INCLUDE_DIRS ${LIBHARDWARE_INCLUDE_DIR})26set(LIBHARDWARE_INCLUDE_DIRS ${LIBHARDWARE_INCLUDE_DIR})
2627
=== modified file 'cmake/LinuxCrossCompile.cmake'
--- cmake/LinuxCrossCompile.cmake 2013-03-13 04:54:15 +0000
+++ cmake/LinuxCrossCompile.cmake 2013-03-29 10:46:21 +0000
@@ -15,11 +15,6 @@
15include_directories(SYSTEM ${MIR_NDK_PATH}/usr/include)15include_directories(SYSTEM ${MIR_NDK_PATH}/usr/include)
16list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${MIR_NDK_PATH}/usr/include")16list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${MIR_NDK_PATH}/usr/include")
1717
18#add directories from the chroot to search for libraries
19link_directories(${MIR_NDK_PATH}/lib/
20 ${MIR_ARM_EABI}/usr/lib
21 ${MIR_NDK_PATH}/usr/lib/${MIR_ARM_EABI})
22
23set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)18set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
24set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)19set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
25set(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,-rpath-link,")20set(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,-rpath-link,")
2621
=== added file 'include/server/mir/logging/glog_logger.h'
--- include/server/mir/logging/glog_logger.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/logging/glog_logger.h 2013-03-29 10:46:21 +0000
@@ -0,0 +1,41 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "mir/logging/logger.h"
20
21namespace mir
22{
23namespace logging
24{
25class GlogLogger : public Logger
26{
27public:
28 GlogLogger(
29 char const* argv0,
30 int stderrthreshold,
31 int minloglevel,
32 std::string const& log_dir);
33
34private:
35 virtual void log(
36 Severity severity,
37 const std::string& message,
38 const std::string& component);
39};
40}
41}
042
=== modified file 'include/server/mir/logging/logger.h'
--- include/server/mir/logging/logger.h 2013-03-13 04:54:15 +0000
+++ include/server/mir/logging/logger.h 2013-03-29 10:46:21 +0000
@@ -39,8 +39,6 @@
39 debug = 439 debug = 4
40 };40 };
4141
42 virtual ~Logger() {}
43
44 template<Severity severity>42 template<Severity severity>
45 void log(const std::string& message)43 void log(const std::string& message)
46 {44 {
@@ -56,6 +54,7 @@
5654
57protected:55protected:
58 Logger() {}56 Logger() {}
57 virtual ~Logger() = default;
59 Logger(const Logger&) = delete;58 Logger(const Logger&) = delete;
60 Logger& operator=(const Logger&) = delete;59 Logger& operator=(const Logger&) = delete;
6160
6261
=== modified file 'src/server/CMakeLists.txt'
--- src/server/CMakeLists.txt 2013-03-28 12:13:18 +0000
+++ src/server/CMakeLists.txt 2013-03-29 10:46:21 +0000
@@ -20,6 +20,9 @@
20 ${CMAKE_CURRENT_BINARY_DIR}/mirserver.pc20 ${CMAKE_CURRENT_BINARY_DIR}/mirserver.pc
21)21)
2222
23MESSAGE(STATUS "GLog_LIBRARY=" ${GLog_LIBRARY})
24MESSAGE(STATUS "GLog_LIBRARY=" ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
25
23set(26set(
24 SRCS27 SRCS
25 run_mir.cpp28 run_mir.cpp
@@ -57,6 +60,7 @@
57 mirprotobuf60 mirprotobuf
58 3rd_party61 3rd_party
59 ${Boost_LIBRARIES}62 ${Boost_LIBRARIES}
63 ${GLog_LIBRARY}
60)64)
6165
62if(${MIRSERVER_LINKAGE} STREQUAL SHARED)66if(${MIRSERVER_LINKAGE} STREQUAL SHARED)
6367
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2013-03-28 09:47:22 +0000
+++ src/server/default_server_configuration.cpp 2013-03-29 10:46:21 +0000
@@ -46,6 +46,7 @@
46#include "mir/input/input_manager.h"46#include "mir/input/input_manager.h"
47#include "mir/logging/logger.h"47#include "mir/logging/logger.h"
48#include "mir/logging/dumb_console_logger.h"48#include "mir/logging/dumb_console_logger.h"
49#include "mir/logging/glog_logger.h"
49#include "mir/logging/session_mediator_report.h"50#include "mir/logging/session_mediator_report.h"
50#include "mir/logging/message_processor_report.h"51#include "mir/logging/message_processor_report.h"
51#include "mir/logging/display_report.h"52#include "mir/logging/display_report.h"
@@ -125,6 +126,11 @@
125char const* const log_msg_processor = "log-msg-processor";126char const* const log_msg_processor = "log-msg-processor";
126char const* const log_display = "log-display";127char const* const log_display = "log-display";
127128
129char const* const glog = "glog";
130char const* const glog_stderrthreshold = "glog-stderrthreshold";
131char const* const glog_minloglevel = "glog-minloglevel";
132char const* const glog_log_dir = "glog-log-dir";
133
128boost::program_options::options_description program_options()134boost::program_options::options_description program_options()
129{135{
130 namespace po = boost::program_options;136 namespace po = boost::program_options;
@@ -133,13 +139,26 @@
133 "Command-line options.\n"139 "Command-line options.\n"
134 "Environment variables capitalise long form with prefix \"MIR_SERVER_\" and \"_\" in place of \"-\"");140 "Environment variables capitalise long form with prefix \"MIR_SERVER_\" and \"_\" in place of \"-\"");
135 desc.add_options()141 desc.add_options()
136 ("file,f", po::value<std::string>(), "socket filename")142 ("file,f", po::value<std::string>(), "Socket filename")
137 ("ipc-thread-pool,i", po::value<int>(), "threads in frontend thread pool")143 (log_display, po::value<bool>(), "Log the Display report. [bool:default=false]")
138 (log_display, po::value<bool>(), "log the Display report")144 (log_app_mediator, po::value<bool>(), "Log the ApplicationMediator report. [bool:default=false]")
139 (log_app_mediator, po::value<bool>(), "log the ApplicationMediator report")
140 (log_msg_processor, po::value<bool>(), "log the MessageProcessor report")145 (log_msg_processor, po::value<bool>(), "log the MessageProcessor report")
141 ("tests-use-real-graphics", po::value<bool>(), "use real graphics in tests")146 (glog, "Use google::GLog for logging")
142 ("tests-use-real-input", po::value<bool>(), "use real input in tests");147 (glog_stderrthreshold, po::value<int>(),"Copy log messages at or above this level "
148 "to stderr in addition to logfiles. The numbers "
149 "of severity levels INFO, WARNING, ERROR, and "
150 "FATAL are 0, 1, 2, and 3, respectively."
151 " [int:default=2]")
152 (glog_minloglevel, po::value<int>(), "Log messages at or above this level. The numbers "
153 "of severity levels INFO, WARNING, ERROR, and "
154 "FATAL are 0, 1, 2, and 3, respectively."
155 " [int:default=0]")
156 (glog_log_dir, po::value<std::string>(),"If specified, logfiles are written into this "
157 "directory instead of the default logging directory."
158 " [string:default=\"\"]")
159 ("ipc-thread-pool,i", po::value<int>(), "threads in frontend thread pool. [int:default=10]")
160 ("tests-use-real-graphics", po::value<bool>(), "Use real graphics in tests. [bool:default=false]")
161 ("tests-use-real-input", po::value<bool>(), "Use real input in tests. [bool:default=false]");
143162
144 return desc;163 return desc;
145}164}
@@ -456,10 +475,20 @@
456std::shared_ptr<ml::Logger> mir::DefaultServerConfiguration::the_logger()475std::shared_ptr<ml::Logger> mir::DefaultServerConfiguration::the_logger()
457{476{
458 return logger(477 return logger(
459 [this]()478 [this]() -> std::shared_ptr<ml::Logger>
460 {479 {
461 // TODO use the_options() to configure logging480 if (the_options()->is_set(glog))
462 return std::make_shared<ml::DumbConsoleLogger>();481 {
482 return std::make_shared<ml::GlogLogger>(
483 "mir",
484 the_options()->get(glog_stderrthreshold, 2),
485 the_options()->get(glog_minloglevel, 0),
486 the_options()->get(glog_log_dir, ""));
487 }
488 else
489 {
490 return std::make_shared<ml::DumbConsoleLogger>();
491 }
463 });492 });
464}493}
465494
466495
=== modified file 'src/server/logging/CMakeLists.txt'
--- src/server/logging/CMakeLists.txt 2013-03-25 15:15:53 +0000
+++ src/server/logging/CMakeLists.txt 2013-03-29 10:46:21 +0000
@@ -2,6 +2,7 @@
2 LOGGING_SOURCES2 LOGGING_SOURCES
33
4 dumb_console_logger.cpp4 dumb_console_logger.cpp
5 glog_logger.cpp
5 session_mediator_report.cpp6 session_mediator_report.cpp
6 message_processor_report.cpp7 message_processor_report.cpp
7 display_report.cpp8 display_report.cpp
89
=== added file 'src/server/logging/glog_logger.cpp'
--- src/server/logging/glog_logger.cpp 1970-01-01 00:00:00 +0000
+++ src/server/logging/glog_logger.cpp 2013-03-29 10:46:21 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "mir/logging/glog_logger.h"
20
21#include <glog/logging.h>
22
23#include <mutex>
24#include <cstdlib>
25
26mir::logging::GlogLogger::GlogLogger(
27 const char* argv0,
28 int stderrthreshold,
29 int minloglevel,
30 std::string const& log_dir)
31{
32 FLAGS_stderrthreshold = stderrthreshold;
33 FLAGS_minloglevel = minloglevel;
34 FLAGS_log_dir = log_dir;
35
36 static std::once_flag init_flag;
37
38 std::call_once(init_flag, [=]() { google::InitGoogleLogging(argv0); });
39}
40
41void mir::logging::GlogLogger::log(Severity severity, const std::string& message, const std::string& component)
42{
43 static int glog_level[] =
44 {
45 google::GLOG_FATAL, // critical = 0,
46 google::GLOG_ERROR, // error = 1,
47 google::GLOG_WARNING, // warning = 2,
48 google::GLOG_INFO, // informational = 3,
49 google::GLOG_INFO, // debug = 4
50 };
51
52 // Since we're not collecting __FILE__ or __LINE__ this is misleading
53 google::LogMessage(__FILE__, __LINE__, glog_level[severity]).stream()
54 << '[' << component << "] " << message;
55}
056
=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_display.cpp'
--- tests/unit-tests/graphics/gbm/test_gbm_display.cpp 2013-03-13 08:09:52 +0000
+++ tests/unit-tests/graphics/gbm/test_gbm_display.cpp 2013-03-29 10:46:21 +0000
@@ -44,6 +44,8 @@
44{44{
45 MOCK_METHOD3(log,45 MOCK_METHOD3(log,
46 void(ml::Logger::Severity, const std::string&, const std::string&));46 void(ml::Logger::Severity, const std::string&, const std::string&));
47
48 ~MockLogger() noexcept(true) {}
47};49};
4850
49class GBMDisplayTest : public ::testing::Test51class GBMDisplayTest : public ::testing::Test
5052
=== modified file 'tests/unit-tests/logging/message_processor_report.cpp'
--- tests/unit-tests/logging/message_processor_report.cpp 2013-03-27 17:18:33 +0000
+++ tests/unit-tests/logging/message_processor_report.cpp 2013-03-29 10:46:21 +0000
@@ -40,6 +40,7 @@
40{40{
41public:41public:
42 MOCK_METHOD3(log, void(Severity severity, const std::string& message, const std::string& component));42 MOCK_METHOD3(log, void(Severity severity, const std::string& message, const std::string& component));
43 ~MockLogger() noexcept(true) {}
43};44};
4445
45struct MessageProcessorReport : public Test46struct MessageProcessorReport : public Test
4647
=== modified file 'tools/setup-partial-armhf-chroot.sh'
--- tools/setup-partial-armhf-chroot.sh 2013-03-26 15:55:51 +0000
+++ tools/setup-partial-armhf-chroot.sh 2013-03-29 10:46:21 +0000
@@ -86,6 +86,12 @@
86 if [ ! -f libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb ]; then86 if [ ! -f libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb ]; then
87 wget "http://launchpadlibrarian.net/134086853/libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb"87 wget "http://launchpadlibrarian.net/134086853/libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb"
88 fi88 fi
89
90 if [ ! -f libgflags-dev_2.0-1_armhf.deb ]; then
91 wget "http://launchpadlibrarian.net/106868249/libgflags-dev_2.0-1_armhf.deb"
92 fi
93
94 dpkg -x libgflags-dev_2.0-1_armhf.deb .
89 dpkg -x libgflags2_2.0-1_armhf.deb .95 dpkg -x libgflags2_2.0-1_armhf.deb .
90 dpkg -x libgoogle-glog0_0.3.2-4ubuntu1_armhf.deb .96 dpkg -x libgoogle-glog0_0.3.2-4ubuntu1_armhf.deb .
91 dpkg -x libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb .97 dpkg -x libgoogle-glog-dev_0.3.2-4ubuntu1_armhf.deb .

Subscribers

People subscribed via source and target branches