Mir

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

Proposed by Daniel van Vugt
Status: Work in progress
Proposed branch: lp:~vanvugt/mir/log-level
Merge into: lp:mir
Diff against target: 720 lines (+138/-83)
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 (+10/-0)
platform-ABI-sha1sums (+1/-1)
server-ABI-sha1sums (+1/-1)
src/client/default_connection_configuration.cpp (+5/-2)
src/client/logging/input_receiver_report.cpp (+2/-1)
src/client/logging/perf_report.cpp (+1/-0)
src/client/logging/rpc_report.cpp (+7/-6)
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 (+2/-1)
src/server/default_server_configuration.cpp (+5/-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
Alan Griffiths Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Needs Fixing
Robert Carr (community) Abstain
Mir development team Pending
Review via email: mp+246092@code.launchpad.net

This proposal supersedes a proposal from 2015-01-07.

Commit message

Set sane limits on how much logging is output by default:
  Servers: Log everything.
  Clients: Log errors only by default, or more if a report requires.
  Nested servers (which are also clients): Log everything.

(LP: #1414883)

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
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

>> 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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

> 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
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: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

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 :).

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

It's just a matter of annoyance. Mir (like GTK) should only pollute your terminal if you do something wrong (hence errors and worse). Otherwise the terminal output should be reserved for the app itself to use. It's unacceptable for a bug-free app to be ported to Mir and get log messages sent to its stdout against its will.

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

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

Unless you miss the logging from a test which has failed and hard to reproduce. On the other hand, when would clean test output ever help? The termination of the test suite will always be clean, and you can see if there was a failure at this stage. At this point you can use your terminal to locate "FAIL"

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

BTW, in this new version of the proposal I'm not changing the logging in tests. We don't need to discuss that here - I've separated it.

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

I agree about clients not spamming stdout/stderr but I don't like this solution.

The problem is with the logging::log() behaviour (not the reports) so there should be no need to interfere with the logging::Log hierarchy. Doing so makes this whole proposal overly complex and risks interfering with reports that may be requested. (Not to mention having two logging level settings in glog is weird.)

All that is needed is a logging::set_level() function and a namespace scope variable to set the logging level that it shares with logging::log().

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

Yeah I can see we only have a stdout issue here. If we can just "fix" DumbConsolerLogger and nothing else then we should. The problem is; everything else in Mir works with a generic Logger. Even:
  void set_logger(std::shared_ptr<Logger> const& new_logger);
indicates that the default process-wide logger can be any implementation. So we need to touch the generic Logger interface.

I'm not sure how set_level could be made safe and reliable. I've implemented raise_level instead, because that guarantees all callers' requests are honoured (the log level never decreases to less than you need).

"The problem is with the logging::log()" ... I'm not sure it's a good idea to provide different behaviour for log() vs somelogger->log(). Sounds like it would be quite inconsistent, which this current proposal is not.

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

Hmm... what if I dropped the reports' raise_level hacks and modified the reports to accept:
   MIR_SOMETHING_REPORT=log-<level>
?

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

Another option would be to add an always-reported output option to the
Logger interface?

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

You're suggesting severity become a two dimensional quantity instead of one? I would rather avoid that.

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

I'm suggesting that severity not be the sole determinant of whether or not a message is printed. I don't think that's making severity two-dimensional, though.

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

It is two dimensional kind of. I understand what you're suggesting but it sounds like more of a hack than what's proposed here. Or what I proposed in MIR_SOMETHING_REPORT=log-<level>.

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

Ah. Actually my latest suggestion won't work. We still need raise_level to cover the nested server case.

Revision history for this message
Robert Carr (robertcarr) :
review: Abstain
Revision history for this message
Chris Halse Rogers (raof) wrote :

I think this exposes a flaw in our architecture for logging/reporting; namely, that they're two separate things, but we've only got one Logger interface to support both.

I think we need an interface for reporting that is separate from the interface for logging. This is not a hack, this is the *undoing* of a hack.

Regardless of the outcome of that particular discussion, we've got severity/raise_level the wrong way around. debug is not a higher severity than critical :)

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

Good point; by raise_level I think I meant raise_verbosity. That's confusing.

Although we could resolve the reporting issue with:
   MIR_SOMETHING_REPORT=log-<level>
which I think would be preferable to adding some "reporting" log level that exists outside the present one-dimensional range of Severity.

For servers, the reporting issue could be resolved trivially by making sure all reports are Info level. And all servers always log Info level anyway. That only leaves the reporting log level problem an issue for clients.

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

Isn't the suggestion “just mandate that all reports are Info level” a pretty obvious indication that reports don't have a reporting level?

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

Just to be clear, I'm not suggesting adding a “reporting” log level. I'm suggesting that the Logger (or possibly an entirely separate thing) grow a report() interface. Mandating that reports must use the Info severity is exactly the same as adding that interface but without any compiler checking.

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

That would create some two-way coupling where really we want to keep it one-way...
Reports sometimes use Loggers. Loggers shouldn't know that reports exist.

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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~vanvugt/mir/log-level updated
2230. By Daniel van Vugt

Merge latest trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~vanvugt/mir/log-level updated
2231. By Daniel van Vugt

Merge latest trunk

2232. By Daniel van Vugt

Merge latest trunk and fix conflicts.

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

Hmm, this is tricky now. Breaking the mircommon ABI might be off limits until we resolve bug 1415321.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~vanvugt/mir/log-level updated
2233. By Daniel van Vugt

Merge latest trunk and fix the same conflict, again.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Needs more reviewers now. I think I've found a reasonable middle ground based on previous review comments...

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

I think Chris is right w.r.t. report interface on the logger.

Daniel wrote:
"That would create some two-way coupling where really we want to keep it one-way...
Reports sometimes use Loggers. Loggers shouldn't know that reports exist."

I expect we could use a seperate interface, Reports then would use reporters which of course know that reports exist. Of course in implementation it may be the same logger object.

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

I still think this is conflating (at least) two issues.

As things are (without this MP) specific loggers can be configured to handle different logging levels differently. E.g. --glog-minloglevel constrains the levels that are logged and --glog-stderrthreshold determines which levels are written to stderr.

Point 1: This functionality already exists in GlogLogger I see no reason to add it there again:
61 +void mir::examples::GlogLogger::enable(ml::Severity severity)

Reports can optionally write to the logger and, by specifying different logging levels for their messages, enable the above capabilities. But the reports should not decide how the logger handles these levels:

Point 2: The fact that a report is writing log messages is no guarantee that those messages should appear:

168 + logger->enable(ml::Severity::informational);

Users of the global logging functions can also exploit this capability by specifying different logging levels for their messages. What doesn't currently exist is an option (as already exists for the reports) of not writing these messages to the logger.

Trying to control the global logging functions via an enable(ml::Severity severity) function in the base class is primitive compared to what users can already do using glog.

We already have logging suppressed (by default - it's an option "--logging [on|off]") in the test framework and AFAICS providing the same (or similar) facility to clients would meet the desire for quiet clients without the complexity and inflexibility of this approach.

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

OK, I have a more palatable alternative proposed:
https://code.launchpad.net/~vanvugt/mir/no-common-log/+merge/248764

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

Subscribers

People subscribed via source and target branches