Mir

Merge lp:~vanvugt/mir/log-level into lp:mir

Proposed by Daniel van Vugt
Status: Superseded
Proposed branch: lp:~vanvugt/mir/log-level
Merge into: lp:mir
Diff against target: 689 lines (+142/-90)
29 files modified
common-ABI-sha1sums (+1/-1)
debian/control (+2/-2)
debian/libmircommon4.install (+1/-1)
examples/glog_logger.cpp (+9/-0)
examples/glog_logger.h (+4/-0)
include/common/mir/logging/logger.h (+11/-0)
platform-ABI-sha1sums (+1/-1)
server-ABI-sha1sums (+1/-1)
src/client/default_connection_configuration.cpp (+4/-2)
src/client/logging/input_receiver_report.cpp (+2/-0)
src/client/logging/perf_report.cpp (+2/-0)
src/client/logging/rpc_report.cpp (+2/-0)
src/common/CMakeLists.txt (+1/-1)
src/common/logging/dumb_console_logger.cpp (+9/-1)
src/common/logging/dumb_console_logger.h (+3/-2)
src/common/logging/logger.cpp (+3/-3)
src/common/symbols.map (+11/-15)
src/server/default_server_configuration.cpp (+4/-2)
src/server/display_server.cpp (+2/-0)
tests/include/mir_test_doubles/mock_logger.h (+44/-0)
tests/include/mir_test_doubles/null_logger.h (+1/-0)
tests/mir_test_doubles/null_logger.cpp (+4/-0)
tests/unit-tests/android_input/input_reader.cpp (+5/-17)
tests/unit-tests/graphics/mesa/test_display.cpp (+3/-8)
tests/unit-tests/graphics/test_graphics_platform.cpp (+1/-5)
tests/unit-tests/logging/message_processor_report.cpp (+2/-8)
tests/unit-tests/logging/test_compositor_report.cpp (+4/-1)
tests/unit-tests/logging/test_display_report.cpp (+3/-10)
tests/unit-tests/logging/test_legacy_input_report.cpp (+2/-9)
To merge this branch: bzr merge lp:~vanvugt/mir/log-level
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Needs Fixing
Chris Halse Rogers Needs Fixing
Alan Griffiths Needs Fixing
Robert Carr (community) Needs Information
Review via email: mp+245718@code.launchpad.net

This proposal has been superseded by a proposal from 2015-01-12.

Commit message

Set sane limits on how much logging is output by default:
  Servers: Log everything
  Tests: Log errors only
  Clients: Log errors only by default, or more if a report requires.

Fixes LP: #1408231 and unblocks branch 'server-platform-probing'.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

Needs information/discussion.

I think I understand the logic for servers and clients.

# Servers: Log everything
# Clients: Log errors only by default, or more if a report requires.

A server is unlikely to be run directly by the user, or if it is, is likely to be run by a user
with an interest in log output. Likewise, clients are relatively likely to be run by a user, e.g.
running an app from a terminal.

I don't think I agree with the tests case though:
# Tests: Log errors only

It's easy to see if a test fails and locate the failing test. Either by color coding or searching for "FAIL". All passing test output can be ignored. Why else wouldn't you want the most detailed logging possible for a failing test?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Robert: I think you misinterpret what I mean by logging in tests. It's just one stray message I'm hiding from tests; see bug 1408231. Actually it's a continuation of bug 1394221.

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

50 + void set_level(Severity max_level) { log_level = max_level; }
51 +

We shouldn't have implementation in an interface or in a header. This fails on both counts.

~~~~

63 +std::shared_ptr<Logger> get_logger();

So the only point of this is to be able to set the log level? Why not just set a suitable logger? Or have a set_level() function?

~~~~~

113 + // Ensure clients don't get polluted with Mir information/debug
114 + // messages by default.
115 + ret->set_level(mir::logging::Severity::error);

This play badly with servers that use the client API. We don't want to override their logging defaults.

Also, it would be convenient to configure the logging level at runtime. E.g. environment variable for clients or the command line for servers.

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

>> Robert: I think you misinterpret what I mean by logging in tests. It's just one stray message I'm
>> hiding from tests;

I don't think I did? That log of course isn't useful, but there could be other informational logs from the server which are useful to debugging a failing test right?

Revision history for this message
Chris Halse Rogers (raof) wrote :

I'm actually going to go one further, and say that the log message that you're trying to silence is *exactly* the sort of message you *want* in the test log output. There is nothing more frustrating than trying to fix a test that's broken because the test environment is loading a different version of the code to what you're expecting.

The interaction with the reports looks rather weird. Because you've asked for the InputReceiverReport you'll additionally get a bunch of unrelated messages, too?

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alan:
You might notice in the history I did try for pure virtual. But dropped the idea as it doubled the diff size and still wasn't yet functional. I found it was an extreme case of "if you make this class pure virtual then the coupling and maintenance effort increases unacceptably". I'm undecided but intentionally left it in the history in case it had to be re-attempted.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Chris:
Yes the single message described in bug 1408231 is pretty harmless. The harm is if we don't fix this and more log messages get added later (which we will). Then all tests will get cluttered by all those new log messages too.

lp:~vanvugt/mir/log-level updated
2208. By Daniel van Vugt

Merge latest trunk

2209. By Daniel van Vugt

Merge latest trunk

2210. By Daniel van Vugt

Merge latest trunk

2211. By Daniel van Vugt

Revert r2206.

2212. By Daniel van Vugt

Fix FTBFS: Redundant TestLogger should be NullLogger

2213. By Daniel van Vugt

Update sha1sums

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

> 113 + // Ensure clients don't get polluted with Mir information/debug
> 114 + // messages by default.
> 115 + ret->set_level(mir::logging::Severity::error);
>
> This play badly with servers that use the client API. We don't want to
> override their logging defaults.

Yeah still needs fixing for nested servers.

review: Needs Fixing
lp:~vanvugt/mir/log-level updated
2214. By Daniel van Vugt

Start trying to resolve varying log level demands

2215. By Daniel van Vugt

Convert set_level -> raise_level

2216. By Daniel van Vugt

Update sha1sums

2217. By Daniel van Vugt

Shrink the diff

2218. By Daniel van Vugt

Remove dead code and privatize where possible

2219. By Daniel van Vugt

Ensure servers always log everything

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Hm, on further thought, I think I want the following:

*) Tests run on CI should spew every piece of plausibly useful information available. The cost for missing useful information is high.
*) Enabling a report =log should make just that log's messages output, not change global log verbosity.
*) Some sort of MIR_CLIENT_DEBUG environment variable to set the global client log verbosity.

I don't really mind if hugely verbose logging is not default on local test runs; it's cheap to turn back on.

Furthermore, I think that we *can* output messages to stdout/stderr by default for clients; although they're likely to be run by users from a terminal, users who do that are unlikely to mind some log messages. And if they do, they already hate glib/gtk, which will reliably spew tens to hundreds of lines of messages for lots of apps in normal operation.

We should *also* give clients the ability to hook in their own logger; they can then silence us if they really care.

Alternatively, as Ryan suggests, we could log to the journal :).

lp:~vanvugt/mir/log-level updated
2220. By Daniel van Vugt

Merge latest trunk

2221. By Daniel van Vugt

Merge latest trunk

2222. By Daniel van Vugt

Merge latest trunk

2223. By Daniel van Vugt

Merge latest trunk

2224. By Daniel van Vugt

Merge latest trunk

2225. By Daniel van Vugt

Merge latest trunk

2226. By Daniel van Vugt

Merge latest trunk

2227. By Daniel van Vugt

Merge latest trunk

2228. By Daniel van Vugt

Merge latest trunk

2229. By Daniel van Vugt

Clarify raise_level confusion.

2230. By Daniel van Vugt

Merge latest trunk

2231. By Daniel van Vugt

Merge latest trunk

2232. By Daniel van Vugt

Merge latest trunk and fix conflicts.

2233. By Daniel van Vugt

Merge latest trunk and fix the same conflict, again.

Unmerged revisions

2233. By Daniel van Vugt

Merge latest trunk and fix the same conflict, again.

2232. By Daniel van Vugt

Merge latest trunk and fix conflicts.

2231. By Daniel van Vugt

Merge latest trunk

2230. By Daniel van Vugt

Merge latest trunk

2229. By Daniel van Vugt

Clarify raise_level confusion.

2228. By Daniel van Vugt

Merge latest trunk

2227. By Daniel van Vugt

Merge latest trunk

2226. By Daniel van Vugt

Merge latest trunk

2225. By Daniel van Vugt

Merge latest trunk

2224. By Daniel van Vugt

Merge latest trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common-ABI-sha1sums'
2--- common-ABI-sha1sums 2015-01-06 03:29:48 +0000
3+++ common-ABI-sha1sums 2015-01-12 08:27:02 +0000
4@@ -12,7 +12,7 @@
5 dcf8b8982f138bdde39a241825c610e955cd5e33 include/common/mir/input/input_platform.h
6 208cd6aed5ef5f8f39b3eb86604e4133cb840485 include/common/mir/input/input_receiver_thread.h
7 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
8-2de47e2790d0f7643e23eada2d8aa2987f58d086 include/common/mir/logging/logger.h
9+7dbff3fa320f11529425cb0d32ed30ccfaefdeca include/common/mir/logging/logger.h
10 3c9bd47bbe0764d39aa40ddd27a861557ba1d949 include/common/mir/log.h
11 31b9c24e2ce7194aeea6694e81c160354033d28a include/common/mir/optional_value.h
12 9ae8473df05dd9e048a73797f01a2f34f7447554 include/common/mir/time/types.h
13
14=== modified file 'debian/control'
15--- debian/control 2015-01-08 03:16:37 +0000
16+++ debian/control 2015-01-12 08:27:02 +0000
17@@ -92,7 +92,7 @@
18 Architecture: i386 amd64 armhf arm64
19 Multi-Arch: same
20 Pre-Depends: ${misc:Pre-Depends}
21-Depends: libmircommon3 (= ${binary:Version}),
22+Depends: libmircommon4 (= ${binary:Version}),
23 libprotobuf-dev (>= 2.4.1),
24 libxkbcommon-dev,
25 ${misc:Depends},
26@@ -252,7 +252,7 @@
27 .
28 Contains a tool for stress testing the Mir display server
29
30-Package: libmircommon3
31+Package: libmircommon4
32 Section: libs
33 Architecture: i386 amd64 armhf arm64
34 Multi-Arch: same
35
36=== renamed file 'debian/libmircommon3.install' => 'debian/libmircommon4.install'
37--- debian/libmircommon3.install 2014-12-08 04:03:47 +0000
38+++ debian/libmircommon4.install 2015-01-12 08:27:02 +0000
39@@ -1,1 +1,1 @@
40-usr/lib/*/libmircommon.so.3
41+usr/lib/*/libmircommon.so.4
42
43=== modified file 'examples/glog_logger.cpp'
44--- examples/glog_logger.cpp 2014-11-17 18:26:11 +0000
45+++ examples/glog_logger.cpp 2015-01-12 08:27:02 +0000
46@@ -70,6 +70,9 @@
47
48 void mir::examples::GlogLogger::log(ml::Severity severity, std::string const& message, std::string const& component)
49 {
50+ if (severity > log_level)
51+ return;
52+
53 static int glog_level[] =
54 {
55 google::GLOG_FATAL, // critical = 0,
56@@ -83,3 +86,9 @@
57 google::LogMessage(__FILE__, __LINE__, glog_level[static_cast<int>(severity)]).stream()
58 << '[' << component << "] " << message;
59 }
60+
61+void mir::examples::GlogLogger::raise_level(ml::Severity severity)
62+{
63+ if (severity > log_level)
64+ log_level = severity;
65+}
66
67=== modified file 'examples/glog_logger.h'
68--- examples/glog_logger.h 2014-12-08 04:03:47 +0000
69+++ examples/glog_logger.h 2015-01-12 08:27:02 +0000
70@@ -36,6 +36,10 @@
71 mir::logging::Severity severity,
72 std::string const& message,
73 std::string const& component) override;
74+
75+ void raise_level(mir::logging::Severity) override;
76+
77+ mir::logging::Severity log_level = mir::logging::Severity::debug;
78 };
79 }
80 }
81
82=== modified file 'include/common/mir/logging/logger.h'
83--- include/common/mir/logging/logger.h 2014-12-19 02:31:34 +0000
84+++ include/common/mir/logging/logger.h 2015-01-12 08:27:02 +0000
85@@ -45,6 +45,16 @@
86 const std::string& message,
87 const std::string& component) = 0;
88
89+ /**
90+ * Raise the maximum log level allowed to be output.
91+ * So that a process and multiple components can all share the same
92+ * Logger, we need to guarantee every user's raise_level() specification
93+ * is honoured. This is done by only allowing the log level to be raised
94+ * and never reduced. A request to raise_level to a lower level has no
95+ * effect.
96+ */
97+ virtual void raise_level(Severity max_level) = 0;
98+
99 protected:
100 Logger() {}
101 virtual ~Logger() = default;
102@@ -54,6 +64,7 @@
103
104 void log(Severity severity, const std::string& message, const std::string& component);
105 void set_logger(std::shared_ptr<Logger> const& new_logger);
106+std::shared_ptr<Logger> get_logger();
107
108 }
109 }
110
111=== modified file 'platform-ABI-sha1sums'
112--- platform-ABI-sha1sums 2015-01-08 03:16:37 +0000
113+++ platform-ABI-sha1sums 2015-01-12 08:27:02 +0000
114@@ -12,7 +12,7 @@
115 dcf8b8982f138bdde39a241825c610e955cd5e33 include/common/mir/input/input_platform.h
116 208cd6aed5ef5f8f39b3eb86604e4133cb840485 include/common/mir/input/input_receiver_thread.h
117 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
118-2de47e2790d0f7643e23eada2d8aa2987f58d086 include/common/mir/logging/logger.h
119+7dbff3fa320f11529425cb0d32ed30ccfaefdeca include/common/mir/logging/logger.h
120 3c9bd47bbe0764d39aa40ddd27a861557ba1d949 include/common/mir/log.h
121 31b9c24e2ce7194aeea6694e81c160354033d28a include/common/mir/optional_value.h
122 9ae8473df05dd9e048a73797f01a2f34f7447554 include/common/mir/time/types.h
123
124=== modified file 'server-ABI-sha1sums'
125--- server-ABI-sha1sums 2015-01-08 03:16:37 +0000
126+++ server-ABI-sha1sums 2015-01-12 08:27:02 +0000
127@@ -12,7 +12,7 @@
128 dcf8b8982f138bdde39a241825c610e955cd5e33 include/common/mir/input/input_platform.h
129 208cd6aed5ef5f8f39b3eb86604e4133cb840485 include/common/mir/input/input_receiver_thread.h
130 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
131-2de47e2790d0f7643e23eada2d8aa2987f58d086 include/common/mir/logging/logger.h
132+7dbff3fa320f11529425cb0d32ed30ccfaefdeca include/common/mir/logging/logger.h
133 3c9bd47bbe0764d39aa40ddd27a861557ba1d949 include/common/mir/log.h
134 31b9c24e2ce7194aeea6694e81c160354033d28a include/common/mir/optional_value.h
135 9ae8473df05dd9e048a73797f01a2f34f7447554 include/common/mir/time/types.h
136
137=== modified file 'src/client/default_connection_configuration.cpp'
138--- src/client/default_connection_configuration.cpp 2014-12-17 13:33:13 +0000
139+++ src/client/default_connection_configuration.cpp 2015-01-12 08:27:02 +0000
140@@ -21,7 +21,7 @@
141 #include "display_configuration.h"
142 #include "rpc/make_rpc_channel.h"
143 #include "rpc/null_rpc_report.h"
144-#include "mir/logging/dumb_console_logger.h"
145+#include "mir/logging/logger.h"
146 #include "mir/input/input_platform.h"
147 #include "mir/input/null_input_receiver_report.h"
148 #include "logging/rpc_report.h"
149@@ -102,7 +102,9 @@
150 return logger(
151 []
152 {
153- return std::make_shared<mir::logging::DumbConsoleLogger>();
154+ auto ret = mir::logging::get_logger();
155+ ret->raise_level(mir::logging::Severity::error);
156+ return ret;
157 });
158 }
159
160
161=== modified file 'src/client/logging/input_receiver_report.cpp'
162--- src/client/logging/input_receiver_report.cpp 2014-12-08 04:03:47 +0000
163+++ src/client/logging/input_receiver_report.cpp 2015-01-12 08:27:02 +0000
164@@ -37,6 +37,8 @@
165 mcll::InputReceiverReport::InputReceiverReport(std::shared_ptr<ml::Logger> const& logger)
166 : logger{logger}
167 {
168+ // You asked for it. This logging report needs debug level.
169+ logger->raise_level(ml::Severity::debug);
170 }
171
172 namespace
173
174=== modified file 'src/client/logging/perf_report.cpp'
175--- src/client/logging/perf_report.cpp 2014-11-17 18:26:11 +0000
176+++ src/client/logging/perf_report.cpp 2015-01-12 08:27:02 +0000
177@@ -34,6 +34,8 @@
178 std::make_shared<mir::time::SteadyClock>())
179 , logger(logger)
180 {
181+ // You asked for it...
182+ logger->raise_level(ml::Severity::informational);
183 }
184
185 void logging::PerfReport::display(const char *name, long fps100,
186
187=== modified file 'src/client/logging/rpc_report.cpp'
188--- src/client/logging/rpc_report.cpp 2014-12-08 04:03:47 +0000
189+++ src/client/logging/rpc_report.cpp 2015-01-12 08:27:02 +0000
190@@ -36,6 +36,8 @@
191 mcll::RpcReport::RpcReport(std::shared_ptr<ml::Logger> const& logger)
192 : logger{logger}
193 {
194+ // You asked for it. This logging report needs debug level.
195+ logger->raise_level(ml::Severity::debug);
196 }
197
198 void mcll::RpcReport::invocation_requested(
199
200=== modified file 'src/common/CMakeLists.txt'
201--- src/common/CMakeLists.txt 2014-12-11 17:51:48 +0000
202+++ src/common/CMakeLists.txt 2015-01-12 08:27:02 +0000
203@@ -50,7 +50,7 @@
204 )
205
206 # TODO we need a place to manage ABI and related versioning but use this as placeholder
207-set(MIRCOMMON_ABI 3)
208+set(MIRCOMMON_ABI 4)
209 set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
210
211 set_target_properties(mircommon
212
213=== modified file 'src/common/logging/dumb_console_logger.cpp'
214--- src/common/logging/dumb_console_logger.cpp 2014-11-17 18:26:11 +0000
215+++ src/common/logging/dumb_console_logger.cpp 2015-01-12 08:27:02 +0000
216@@ -16,7 +16,7 @@
217 * Authored by: Thomas Voß <thomas.voss@canonical.com>
218 */
219
220-#include "mir/logging/dumb_console_logger.h"
221+#include "dumb_console_logger.h"
222
223 #include <iostream>
224 #include <ctime>
225@@ -28,6 +28,8 @@
226 const std::string& message,
227 const std::string& component)
228 {
229+ if (severity > log_level)
230+ return;
231
232 static const char* lut[5] =
233 {
234@@ -56,3 +58,9 @@
235 << message
236 << "\n";
237 }
238+
239+void ml::DumbConsoleLogger::raise_level(ml::Severity max)
240+{
241+ if (max > log_level)
242+ log_level = max;
243+}
244
245=== renamed file 'src/include/common/mir/logging/dumb_console_logger.h' => 'src/common/logging/dumb_console_logger.h'
246--- src/include/common/mir/logging/dumb_console_logger.h 2014-12-08 04:03:47 +0000
247+++ src/common/logging/dumb_console_logger.h 2015-01-12 08:27:02 +0000
248@@ -27,10 +27,11 @@
249 {
250 class DumbConsoleLogger : public Logger
251 {
252-public:
253-
254 protected:
255 void log(Severity severity, const std::string& message, const std::string& component) override;
256+ void raise_level(Severity max_level) override;
257+private:
258+ Severity log_level = Severity::critical;
259 };
260 }
261 }
262
263=== modified file 'src/common/logging/logger.cpp'
264--- src/common/logging/logger.cpp 2014-12-19 02:31:34 +0000
265+++ src/common/logging/logger.cpp 2015-01-12 08:27:02 +0000
266@@ -16,7 +16,7 @@
267 * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com>
268 */
269
270-#include "mir/logging/dumb_console_logger.h"
271+#include "dumb_console_logger.h"
272 #include "mir/logging/logger.h"
273
274 #include <memory>
275@@ -28,8 +28,9 @@
276 {
277 std::mutex log_mutex;
278 std::shared_ptr<ml::Logger> the_logger;
279+}
280
281-std::shared_ptr<ml::Logger> get_logger()
282+std::shared_ptr<ml::Logger> ml::get_logger()
283 {
284 if (auto const result = the_logger)
285 {
286@@ -44,7 +45,6 @@
287 return the_logger;
288 }
289 }
290-}
291
292 void ml::log(ml::Severity severity, const std::string& message, const std::string& component)
293 {
294
295=== modified file 'src/common/symbols.map'
296--- src/common/symbols.map 2014-12-19 23:15:04 +0000
297+++ src/common/symbols.map 2015-01-12 08:27:02 +0000
298@@ -1,4 +1,4 @@
299-MIR_COMMON_3 {
300+MIR_COMMON_4 {
301 global: mir_*;
302 extern "C++" {
303 # The following symbols come from running a script over the generated docs. Vis:
304@@ -198,20 +198,16 @@
305 typeinfo?for?mir::fd_reception_error;
306 typeinfo?for?mir::socket_error;
307 typeinfo?for?mir::socket_disconnected_error;
308+
309+ mir_event_get*;
310+ mir_event_get*;
311+ mir_input_event_get*;
312+ mir_key_input_event_get*;
313+ mir_touch_input_event_get*;
314+ mir::log*char*;
315+ mir::logv*;
316+ mir::libraries_for_path*;
317+ mir::logging::get_logger*;
318 };
319 local: *;
320 };
321-
322-MIR_COMMON_3.1 {
323- global:
324- extern "C++" {
325- mir_event_get*;
326- mir_event_get*;
327- mir_input_event_get*;
328- mir_key_input_event_get*;
329- mir_touch_input_event_get*;
330- mir::log*char*;
331- mir::logv*;
332- mir::libraries_for_path*;
333- };
334-} MIR_COMMON_3;
335
336=== modified file 'src/server/default_server_configuration.cpp'
337--- src/server/default_server_configuration.cpp 2014-12-08 04:03:47 +0000
338+++ src/server/default_server_configuration.cpp 2015-01-12 08:27:02 +0000
339@@ -26,7 +26,7 @@
340 #include "mir/emergency_cleanup.h"
341 #include "mir/default_configuration.h"
342
343-#include "mir/logging/dumb_console_logger.h"
344+#include "mir/logging/logger.h"
345 #include "mir/options/program_option.h"
346 #include "mir/frontend/session_credentials.h"
347 #include "mir/frontend/session_authorizer.h"
348@@ -212,6 +212,8 @@
349 return logger(
350 [this]() -> std::shared_ptr<ml::Logger>
351 {
352- return std::make_shared<ml::DumbConsoleLogger>();
353+ auto ret = ml::get_logger();
354+ ret->raise_level(ml::Severity::debug);
355+ return ret;
356 });
357 }
358
359=== modified file 'src/server/display_server.cpp'
360--- src/server/display_server.cpp 2014-12-09 03:14:55 +0000
361+++ src/server/display_server.cpp 2015-01-12 08:27:02 +0000
362@@ -210,6 +210,8 @@
363
364 void mir::DisplayServer::run()
365 {
366+ // Servers should always log everything
367+ mir::logging::get_logger()->raise_level(mir::logging::Severity::debug);
368 mir::log_info("Mir version " MIR_VERSION);
369
370 p->connector->start();
371
372=== added file 'tests/include/mir_test_doubles/mock_logger.h'
373--- tests/include/mir_test_doubles/mock_logger.h 1970-01-01 00:00:00 +0000
374+++ tests/include/mir_test_doubles/mock_logger.h 2015-01-12 08:27:02 +0000
375@@ -0,0 +1,44 @@
376+/*
377+ * Copyright © 2015 Canonical Ltd.
378+ *
379+ * This program is free software: you can redistribute it and/or modify it
380+ * under the terms of the GNU General Public License version 3,
381+ * as published by the Free Software Foundation.
382+ *
383+ * This program is distributed in the hope that it will be useful,
384+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
385+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
386+ * GNU General Public License for more details.
387+ *
388+ * You should have received a copy of the GNU General Public License
389+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
390+ *
391+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
392+ */
393+
394+#ifndef MIR_TEST_DOUBLES_MOCK_LOGGER_H_
395+#define MIR_TEST_DOUBLES_MOCK_LOGGER_H_
396+
397+#include "mir/logging/logger.h"
398+#include <gmock/gmock.h>
399+
400+namespace mir
401+{
402+namespace test
403+{
404+namespace doubles
405+{
406+
407+class MockLogger : public mir::logging::Logger
408+{
409+public:
410+ MOCK_METHOD3(log, void(mir::logging::Severity, const std::string&, const std::string&));
411+ MOCK_METHOD1(raise_level, void(mir::logging::Severity));
412+ ~MockLogger() noexcept(true) {}
413+};
414+
415+} // namespace doubles
416+} // namespace test
417+} // namespace mir
418+
419+#endif /* MIR_TEST_DOUBLES_MOCK_LOGGER_H_ */
420
421=== modified file 'tests/include/mir_test_doubles/null_logger.h'
422--- tests/include/mir_test_doubles/null_logger.h 2014-11-21 11:11:34 +0000
423+++ tests/include/mir_test_doubles/null_logger.h 2015-01-12 08:27:02 +0000
424@@ -34,6 +34,7 @@
425 class NullLogger : public mir::logging::Logger
426 {
427 void log(mir::logging::Severity, const std::string&, const std::string&) override;
428+void raise_level(mir::logging::Severity) override;
429 };
430 }
431 }
432
433=== modified file 'tests/mir_test_doubles/null_logger.cpp'
434--- tests/mir_test_doubles/null_logger.cpp 2014-11-21 11:11:34 +0000
435+++ tests/mir_test_doubles/null_logger.cpp 2015-01-12 08:27:02 +0000
436@@ -26,3 +26,7 @@
437 void mtd::NullLogger::log(mir::logging::Severity, const std::string&, const std::string&)
438 {
439 }
440+
441+void mtd::NullLogger::raise_level(mir::logging::Severity)
442+{
443+}
444
445=== modified file 'tests/unit-tests/android_input/input_reader.cpp'
446--- tests/unit-tests/android_input/input_reader.cpp 2014-12-08 04:03:47 +0000
447+++ tests/unit-tests/android_input/input_reader.cpp 2015-01-12 08:27:02 +0000
448@@ -27,25 +27,13 @@
449 #include "mir/logging/logger.h"
450 #include "mir/report/legacy_input_report.h"
451 #include "mir_test/fake_event_hub.h"
452+#include "mir_test_doubles/null_logger.h"
453
454 namespace ml = mir::logging;
455
456 using std::string;
457 using mir::input::android::FakeEventHub;
458-
459-namespace
460-{
461-class TestLogger : public ml::Logger
462-{
463-public:
464- void log(ml::Severity severity, const string& message, const string& component) override {
465- (void)severity;
466- (void)message;
467- (void)component;
468- }
469-};
470-}
471-
472+using mir::test::doubles::NullLogger;
473
474 namespace android {
475
476@@ -569,7 +557,7 @@
477 sp<InstrumentedInputReader> mReader;
478
479 virtual void SetUp() {
480- mir::report::legacy_input::initialize(std::make_shared<TestLogger>());
481+ mir::report::legacy_input::initialize(std::make_shared<NullLogger>());
482 mReader = new InstrumentedInputReader(mFakeEventHub, mFakePolicy, mFakeListener);
483 }
484
485@@ -790,7 +778,7 @@
486 InputDevice* mDevice;
487
488 virtual void SetUp() {
489- mir::report::legacy_input::initialize(std::make_shared<TestLogger>());
490+ mir::report::legacy_input::initialize(std::make_shared<NullLogger>());
491 mFakeEventHub = new FakeEventHub();
492 mFakePolicy = new FakeInputReaderPolicy();
493 mFakeListener = new FakeInputListener();
494@@ -980,7 +968,7 @@
495 InputDevice* mDevice;
496
497 virtual void SetUp() {
498- mir::report::legacy_input::initialize(std::make_shared<TestLogger>());
499+ mir::report::legacy_input::initialize(std::make_shared<NullLogger>());
500 mFakeEventHub = new FakeEventHub();
501 mFakePolicy = new FakeInputReaderPolicy();
502 mFakeListener = new FakeInputListener();
503
504=== modified file 'tests/unit-tests/graphics/mesa/test_display.cpp'
505--- tests/unit-tests/graphics/mesa/test_display.cpp 2015-01-06 07:05:23 +0000
506+++ tests/unit-tests/graphics/mesa/test_display.cpp 2015-01-12 08:27:02 +0000
507@@ -26,6 +26,7 @@
508 #include "mir/time/steady_clock.h"
509 #include "mir/glib_main_loop.h"
510
511+#include "mir_test_doubles/mock_logger.h"
512 #include "mir_test_doubles/mock_egl.h"
513 #include "mir_test_doubles/mock_gl.h"
514 #include "src/server/report/null_report_factory.h"
515@@ -59,16 +60,10 @@
516 namespace mtf=mir_test_framework;
517 namespace mr=mir::report;
518
519+using MockLogger = mir::test::doubles::MockLogger;
520+
521 namespace
522 {
523-struct MockLogger : public ml::Logger
524-{
525- MOCK_METHOD3(log,
526- void(ml::Severity, const std::string&, const std::string&));
527-
528- ~MockLogger() noexcept(true) {}
529-};
530-
531 class MockEventRegister : public mg::EventHandlerRegister
532 {
533 public:
534
535=== modified file 'tests/unit-tests/graphics/test_graphics_platform.cpp'
536--- tests/unit-tests/graphics/test_graphics_platform.cpp 2014-12-08 04:03:47 +0000
537+++ tests/unit-tests/graphics/test_graphics_platform.cpp 2015-01-12 08:27:02 +0000
538@@ -31,13 +31,11 @@
539 #else
540 #include "mir_test_doubles/mock_android_hw.h"
541 #endif
542-#include "mir/logging/dumb_console_logger.h"
543
544
545 #include <gtest/gtest.h>
546
547 namespace mg = mir::graphics;
548-namespace ml = mir::logging;
549 namespace geom = mir::geometry;
550 namespace mtd = mir::test::doubles;
551 namespace mo = mir::options;
552@@ -48,7 +46,7 @@
553 class GraphicsPlatform : public ::testing::Test
554 {
555 public:
556- GraphicsPlatform() : logger(std::make_shared<ml::DumbConsoleLogger>())
557+ GraphicsPlatform()
558 {
559 using namespace testing;
560
561@@ -71,8 +69,6 @@
562 return mtd::create_platform_with_null_dependencies();
563 }
564
565- std::shared_ptr<ml::Logger> logger;
566-
567 ::testing::NiceMock<mtd::MockEGL> mock_egl;
568 ::testing::NiceMock<mtd::MockGL> mock_gl;
569 #ifdef ANDROID
570
571=== modified file 'tests/unit-tests/logging/message_processor_report.cpp'
572--- tests/unit-tests/logging/message_processor_report.cpp 2014-11-17 18:26:11 +0000
573+++ tests/unit-tests/logging/message_processor_report.cpp 2015-01-12 08:27:02 +0000
574@@ -20,6 +20,7 @@
575 #include "mir/logging/logger.h"
576
577 #include "mir_test/fake_shared.h"
578+#include "mir_test_doubles/mock_logger.h"
579
580 #include <gtest/gtest.h>
581 #include <gmock/gmock.h>
582@@ -40,16 +41,9 @@
583 ~MockClock() noexcept(true) {}
584 };
585
586-class MockLogger : public ml::Logger
587-{
588-public:
589- MOCK_METHOD3(log, void(ml::Severity severity, const std::string& message, const std::string& component));
590- ~MockLogger() noexcept(true) {}
591-};
592-
593 struct MessageProcessorReport : public Test
594 {
595- MockLogger logger;
596+ mir::test::doubles::MockLogger logger;
597 MockClock clock;
598
599 mir::report::logging::MessageProcessorReport report;
600
601=== modified file 'tests/unit-tests/logging/test_compositor_report.cpp'
602--- tests/unit-tests/logging/test_compositor_report.cpp 2014-11-17 18:26:11 +0000
603+++ tests/unit-tests/logging/test_compositor_report.cpp 2015-01-12 08:27:02 +0000
604@@ -36,10 +36,13 @@
605 class Recorder : public ml::Logger
606 {
607 public:
608- void log(ml::Severity, string const& message, string const&)
609+ void log(ml::Severity, string const& message, string const&) override
610 {
611 last = message;
612 }
613+ void raise_level(ml::Severity) override
614+ {
615+ }
616 string const& last_message() const
617 {
618 return last;
619
620=== modified file 'tests/unit-tests/logging/test_display_report.cpp'
621--- tests/unit-tests/logging/test_display_report.cpp 2014-11-17 18:26:11 +0000
622+++ tests/unit-tests/logging/test_display_report.cpp 2015-01-12 08:27:02 +0000
623@@ -17,7 +17,7 @@
624 */
625
626 #include "src/server/report/logging/display_report.h"
627-#include "mir/logging/logger.h"
628+#include "mir_test_doubles/mock_logger.h"
629 #include "mir_test_doubles/mock_egl.h"
630
631 #include <gtest/gtest.h>
632@@ -30,13 +30,6 @@
633
634 namespace
635 {
636-class MockLogger : public ml::Logger
637-{
638-public:
639- MOCK_METHOD3(log, void(ml::Severity severity, const std::string& message, const std::string& component));
640- ~MockLogger() noexcept(true) {}
641-};
642-
643 struct DisplayReport : public testing::Test
644 {
645 DisplayReport()
646@@ -45,10 +38,10 @@
647
648 void SetUp()
649 {
650- logger = std::make_shared<MockLogger>();
651+ logger = std::make_shared<mtd::MockLogger>();
652 }
653
654- std::shared_ptr<MockLogger> logger;
655+ std::shared_ptr<mtd::MockLogger> logger;
656 mtd::MockEGL mock_egl;
657 };
658
659
660=== modified file 'tests/unit-tests/logging/test_legacy_input_report.cpp'
661--- tests/unit-tests/logging/test_legacy_input_report.cpp 2014-11-17 18:26:11 +0000
662+++ tests/unit-tests/logging/test_legacy_input_report.cpp 2015-01-12 08:27:02 +0000
663@@ -17,7 +17,7 @@
664 */
665
666 #include "mir/report/legacy_input_report.h"
667-#include "mir/logging/logger.h"
668+#include "mir_test_doubles/mock_logger.h"
669
670 #include <std/Log.h>
671
672@@ -33,16 +33,9 @@
673
674 namespace
675 {
676-class MockLogger : public ml::Logger
677-{
678-public:
679- MOCK_METHOD3(log, void(ml::Severity severity, const std::string& message, const std::string& component));
680- ~MockLogger() noexcept(true) {}
681-};
682-
683 struct InputReport : public testing::Test
684 {
685- MockLogger logger;
686+ mir::test::doubles::MockLogger logger;
687
688 InputReport()
689 {

Subscribers

People subscribed via source and target branches