Mir

Merge lp:~cemil-azizoglu/mir/fix-chatty-logging-in-tests into lp:mir

Proposed by Cemil Azizoglu
Status: Rejected
Rejected by: Cemil Azizoglu
Proposed branch: lp:~cemil-azizoglu/mir/fix-chatty-logging-in-tests
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/fix-set_logger
Diff against target: 143 lines (+35/-5)
8 files modified
include/platform/mir/options/configuration.h (+1/-0)
src/common/logging/logger.cpp (+1/-2)
src/include/common/mir/logging/logger.h (+8/-0)
src/platform/options/default_configuration.cpp (+4/-2)
src/platform/symbols.map (+1/-0)
src/server/default_server_configuration.cpp (+4/-1)
tests/mir_test_framework/CMakeLists.txt (+6/-0)
tests/mir_test_framework/headless_test.cpp (+10/-0)
To merge this branch: bzr merge lp:~cemil-azizoglu/mir/fix-chatty-logging-in-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Alan Griffiths Needs Fixing
Alexandros Frantzis (community) Needs Fixing
Review via email: mp+242441@code.launchpad.net

Description of the change

Fix https://bugs.launchpad.net/mir/+bug/1394221

- An option was added to send logs to NullLogger.
- Acceptance tests now use this option.

To post a comment you must log in.
2081. By Cemil Azizoglu

Whitespace

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> 3 - server-ABI-unchanged (Failed)
> 6 - platform-ABI-unchanged (Failed)

CI failure.

> 75 + (silent_logger_opt, "Send logs to a black hole.");

Clearer as "--disable-logging", "Disable logging."?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/vivid/universe/i18n/Translation-en Hash Sum mismatch

triggering rebuild

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

*Needs discussion*

I'm not convinced this should be a mirserver option - I think logging should be "always on".

I've MP'd an alternative that only touches the test framework:

lp:~alan-griffiths/mir/fix-1394221/+merge/242477

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

131 +#if !defined(ALLOW_CONSOLE_LOGGING_IN_TESTS)
132 + const int argc = 2;
133 + char const* argv[argc] = {
134 + __PRETTY_FUNCTION__,
135 + "-s" /* --silent-logger */
136 + };
137 +
138 + server.set_command_line(argc, argv);
139 +#endif

needing to recompile to operate a logging switch is not intuitive.

review: Needs Fixing
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)

Unmerged revisions

2081. By Cemil Azizoglu

Whitespace

2080. By Cemil Azizoglu

- Option to turn send logs to a black hole
- Use the option during tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/platform/mir/options/configuration.h'
--- include/platform/mir/options/configuration.h 2014-11-17 13:43:52 +0000
+++ include/platform/mir/options/configuration.h 2014-11-21 00:12:57 +0000
@@ -45,6 +45,7 @@
45extern char const* const fatal_abort_opt;45extern char const* const fatal_abort_opt;
46extern char const* const debug_opt;46extern char const* const debug_opt;
47extern char const* const use_asio_main_loop_opt;47extern char const* const use_asio_main_loop_opt;
48extern char const* const silent_logger_opt;
4849
49extern char const* const name_opt;50extern char const* const name_opt;
50extern char const* const offscreen_opt;51extern char const* const offscreen_opt;
5152
=== modified file 'src/common/logging/logger.cpp'
--- src/common/logging/logger.cpp 2014-11-17 18:26:11 +0000
+++ src/common/logging/logger.cpp 2014-11-21 00:12:57 +0000
@@ -16,7 +16,6 @@
16 * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com>16 * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com>
17 */17 */
1818
19#include "mir/logging/dumb_console_logger.h"
20#include "mir/logging/logger.h"19#include "mir/logging/logger.h"
2120
22#include <memory>21#include <memory>
@@ -39,7 +38,7 @@
39 {38 {
40 std::lock_guard<decltype(log_mutex)> lock{log_mutex};39 std::lock_guard<decltype(log_mutex)> lock{log_mutex};
41 if (!the_logger)40 if (!the_logger)
42 the_logger = std::make_shared<ml::DumbConsoleLogger>();41 the_logger = std::make_shared<ml::NullLogger>();
4342
44 return the_logger;43 return the_logger;
45 }44 }
4645
=== modified file 'src/include/common/mir/logging/logger.h'
--- src/include/common/mir/logging/logger.h 2014-11-17 18:26:11 +0000
+++ src/include/common/mir/logging/logger.h 2014-11-21 00:12:57 +0000
@@ -52,6 +52,14 @@
52 Logger& operator=(const Logger&) = delete;52 Logger& operator=(const Logger&) = delete;
53};53};
5454
55class NullLogger : public Logger
56{
57public:
58 void log(Severity,
59 const std::string&,
60 const std::string&) override {}
61};
62
55void log(Severity severity, const std::string& message);63void log(Severity severity, const std::string& message);
56void log(Severity severity, const std::string& message, const std::string& component);64void log(Severity severity, const std::string& message, const std::string& component);
57void set_logger(std::shared_ptr<Logger> const& new_logger);65void set_logger(std::shared_ptr<Logger> const& new_logger);
5866
=== modified file 'src/platform/options/default_configuration.cpp'
--- src/platform/options/default_configuration.cpp 2014-11-17 13:43:52 +0000
+++ src/platform/options/default_configuration.cpp 2014-11-21 00:12:57 +0000
@@ -43,10 +43,11 @@
43char const* const mo::frontend_threads_opt = "ipc-thread-pool";43char const* const mo::frontend_threads_opt = "ipc-thread-pool";
44char const* const mo::name_opt = "name";44char const* const mo::name_opt = "name";
45char const* const mo::offscreen_opt = "offscreen";45char const* const mo::offscreen_opt = "offscreen";
46char const* const mo::touchspots_opt = "enable-touchspots";46char const* const mo::touchspots_opt = "enable-touchspots";
47char const* const mo::fatal_abort_opt = "on-fatal-error-abort";47char const* const mo::fatal_abort_opt = "on-fatal-error-abort";
48char const* const mo::debug_opt = "debug";48char const* const mo::debug_opt = "debug";
49char const* const mo::use_asio_main_loop_opt = "use-asio-main-loop";49char const* const mo::use_asio_main_loop_opt = "use-asio-main-loop";
50char const* const mo::silent_logger_opt = "silent-logger,s";
5051
51char const* const mo::off_opt_value = "off";52char const* const mo::off_opt_value = "off";
52char const* const mo::log_opt_value = "log";53char const* const mo::log_opt_value = "log";
@@ -147,7 +148,8 @@
147 "in unexpected ways] abort (to get a core dump)")148 "in unexpected ways] abort (to get a core dump)")
148 (debug_opt, "Enable extra development debugging. "149 (debug_opt, "Enable extra development debugging. "
149 "This is only interesting for people doing Mir server or client development.")150 "This is only interesting for people doing Mir server or client development.")
150 (use_asio_main_loop_opt, "Use the ASIO main loop implementation");151 (use_asio_main_loop_opt, "Use the ASIO main loop implementation")
152 (silent_logger_opt, "Send logs to a black hole.");
151153
152 add_platform_options();154 add_platform_options();
153}155}
154156
=== modified file 'src/platform/symbols.map'
--- src/platform/symbols.map 2014-11-19 13:45:25 +0000
+++ src/platform/symbols.map 2014-11-21 00:12:57 +0000
@@ -178,6 +178,7 @@
178 mir::options::session_mediator_report_opt*;178 mir::options::session_mediator_report_opt*;
179 mir::options::touchspots_opt*;179 mir::options::touchspots_opt*;
180 mir::options::use_asio_main_loop_opt*;180 mir::options::use_asio_main_loop_opt*;
181 mir::options::silent_logger_opt*;
181 non-virtual?thunk?to?mir::graphics::Cursor::?Cursor*;182 non-virtual?thunk?to?mir::graphics::Cursor::?Cursor*;
182 non-virtual?thunk?to?mir::graphics::CursorImage::?CursorImage*;183 non-virtual?thunk?to?mir::graphics::CursorImage::?CursorImage*;
183 non-virtual?thunk?to?mir::graphics::DisplayConfigurationPolicy::?DisplayConfigurationPolicy*;184 non-virtual?thunk?to?mir::graphics::DisplayConfigurationPolicy::?DisplayConfigurationPolicy*;
184185
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2014-11-17 13:43:52 +0000
+++ src/server/default_server_configuration.cpp 2014-11-21 00:12:57 +0000
@@ -212,6 +212,9 @@
212 return logger(212 return logger(
213 [this]() -> std::shared_ptr<ml::Logger>213 [this]() -> std::shared_ptr<ml::Logger>
214 {214 {
215 return std::make_shared<ml::DumbConsoleLogger>();215 if (the_options()->is_set(options::silent_logger_opt))
216 return std::make_shared<ml::NullLogger>();
217 else
218 return std::make_shared<ml::DumbConsoleLogger>();
216 });219 });
217}220}
218221
=== modified file 'tests/mir_test_framework/CMakeLists.txt'
--- tests/mir_test_framework/CMakeLists.txt 2014-11-18 16:15:00 +0000
+++ tests/mir_test_framework/CMakeLists.txt 2014-11-21 00:12:57 +0000
@@ -35,6 +35,12 @@
35 fake_event_hub_server_configuration.cpp35 fake_event_hub_server_configuration.cpp
36)36)
3737
38option(MIR_ALLOW_CONSOLE_LOGGING_IN_TESTS "Allow logs to stdout during tests" OFF)
39
40if (MIR_ALLOW_CONSOLE_LOGGING_IN_TESTS)
41add_definitions(-DALLOW_CONSOLE_LOGGING_IN_TESTS)
42endif (MIR_ALLOW_CONSOLE_LOGGING_IN_TESTS)
43
38list(APPEND TEST_FRAMEWORK_SRCS44list(APPEND TEST_FRAMEWORK_SRCS
39 socket_detect_server.cpp45 socket_detect_server.cpp
40)46)
4147
=== modified file 'tests/mir_test_framework/headless_test.cpp'
--- tests/mir_test_framework/headless_test.cpp 2014-11-06 03:56:24 +0000
+++ tests/mir_test_framework/headless_test.cpp 2014-11-21 00:12:57 +0000
@@ -42,6 +42,16 @@
4242
43void mtf::HeadlessTest::start_server()43void mtf::HeadlessTest::start_server()
44{44{
45#if !defined(ALLOW_CONSOLE_LOGGING_IN_TESTS)
46 const int argc = 2;
47 char const* argv[argc] = {
48 __PRETTY_FUNCTION__,
49 "-s" /* --silent-logger */
50 };
51
52 server.set_command_line(argc, argv);
53#endif
54
45 server.add_init_callback([&]55 server.add_init_callback([&]
46 {56 {
47 auto const main_loop = server.the_main_loop();57 auto const main_loop = server.the_main_loop();

Subscribers

People subscribed via source and target branches