Mir

Merge lp:~alan-griffiths/mir/make-set_logger-for-client-reports into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 3379
Proposed branch: lp:~alan-griffiths/mir/make-set_logger-for-client-reports
Merge into: lp:mir
Prerequisite: lp:~vanvugt/mir/fix-1546933-2
Diff against target: 130 lines (+28/-40)
2 files modified
src/client/default_connection_configuration.cpp (+9/-5)
tests/acceptance-tests/test_client_logging.cpp (+19/-35)
To merge this branch: bzr merge lp:~alan-griffiths/mir/make-set_logger-for-client-reports
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve
Cemil Azizoglu (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+288118@code.launchpad.net

Commit message

client: Make mir::logging::set_logger() work for client reports

Description of the change

client: Make mir::logging::set_logger() work for client reports

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3383
https://mir-jenkins.ubuntu.com/job/mir-ci/497/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/336
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/363
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/355
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/355
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/345
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/345/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/345
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/345/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/345
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/345/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/345
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/345/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/345
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/345/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/497/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3385
https://mir-jenkins.ubuntu.com/job/mir-ci/506/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/352
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/382
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/374
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/374
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/361
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/361/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/361
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/361/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/361
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/361/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/361
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/361/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/361
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/361/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/506/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3387
https://mir-jenkins.ubuntu.com/job/mir-ci/510/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/359
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/389
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/381
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/381
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/368
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/368/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/368
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/368/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/368
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/368/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/368
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/368/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/368
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/368/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/510/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Huh. I thought we were trying to make mirclient independent of mircommon? This ties them together more.

As it stands, this is really only going to be useful in tests, right? I rather thought you might take this opportunity to add a client-facing mirclient log API (which we need at some point).

This doesn't seem wrong, though. Unless we haven't given up on making mirclient not depend on mircommon?

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

> Huh. I thought we were trying to make mirclient independent of mircommon? This
> ties them together more.

I don't recognise that aspiration. Nor do I think it feasible.

> As it stands, this is really only going to be useful in tests, right?

Yes.

> I rather
> thought you might take this opportunity to add a client-facing mirclient log
> API (which we need at some point).

Providing a C style API for customizing the logging is a significantly bigger change than this simplification.

> This doesn't seem wrong, though. Unless we haven't given up on making
> mirclient not depend on mircommon?

It could be wrong, if we decide that this mechanism for customizing logging should be deprecated. (See discussion in linked the bug.)

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Looks good

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

On Tue, Mar 8, 2016 at 8:43 PM, Alan Griffiths <email address hidden>
wrote:
>> Huh. I thought we were trying to make mirclient independent of
>> mircommon? This
>> ties them together more.
>
> I don't recognise that aspiration. Nor do I think it feasible.

I'm pretty sure I recall that *you've* marked one of my merge-proposals
as Needs Fixing because “mircommon is supposed to be the things
shared between the server and the platform” ☺.

But anyway, if that's not a thing we're going for, then sure.

Revision history for this message
Chris Halse Rogers (raof) :
review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

On 08/03/16 23:39, Chris Halse Rogers wrote:
> I'm pretty sure I recall that *you've* marked one of my merge-proposals
> as Needs Fixing because “mircommon is supposed to be the things
> shared between the server and the platform” ☺.

Maybe I was confused? That describes mirplatform.

--
Alan Griffiths +44 (0)798 9938 758
Octopull Ltd http://www.octopull.co.uk/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/default_connection_configuration.cpp'
2--- src/client/default_connection_configuration.cpp 2016-01-29 08:18:22 +0000
3+++ src/client/default_connection_configuration.cpp 2016-03-07 14:29:24 +0000
4@@ -21,7 +21,7 @@
5 #include "display_configuration.h"
6 #include "rpc/make_rpc_channel.h"
7 #include "rpc/null_rpc_report.h"
8-#include "mir/logging/dumb_console_logger.h"
9+#include "mir/logging/logger.h"
10 #include "mir/input/input_platform.h"
11 #include "mir/input/input_devices.h"
12 #include "mir/input/null_input_receiver_report.h"
13@@ -76,11 +76,15 @@
14 std::shared_ptr<mir::logging::Logger>
15 mcl::DefaultConnectionConfiguration::the_logger()
16 {
17- return logger(
18- []
19+ class ProxyLogger : public mir::logging::Logger
20+ {
21+ void log(mir::logging::Severity severity, const std::string& message, const std::string& component) override
22 {
23- return std::make_shared<mir::logging::DumbConsoleLogger>();
24- });
25+ mir::logging::log(severity, message, component);
26+ }
27+ };
28+
29+ return logger([]{ return std::make_shared<ProxyLogger>(); });
30 }
31
32 std::shared_ptr<mcl::ClientPlatformFactory>
33
34=== modified file 'tests/acceptance-tests/test_client_logging.cpp'
35--- tests/acceptance-tests/test_client_logging.cpp 2016-03-07 14:29:24 +0000
36+++ tests/acceptance-tests/test_client_logging.cpp 2016-03-07 14:29:24 +0000
37@@ -17,10 +17,9 @@
38 */
39
40 #include "mir_toolkit/mir_client_library.h"
41-#include "mir_test_framework/stub_client_connection_configuration.h"
42-#include "mir_test_framework/using_client_platform.h"
43 #include "mir_test_framework/connected_client_headless_server.h"
44 #include "mir/logging/logger.h"
45+#include "mir/test/fake_shared.h"
46
47 #include <gmock/gmock.h>
48 #include <gtest/gtest.h>
49@@ -30,49 +29,34 @@
50 using namespace testing;
51 using namespace mir_test_framework;
52
53-namespace {
54-
55+namespace
56+{
57 class StringStreamLogger : public mir::logging::Logger
58 {
59 public:
60- void log(mir::logging::Severity,
61- std::string const& message,
62- std::string const& component) override
63- {
64- ss << "[StringStreamLogger] "
65- << component << ": " << message << std::endl;
66- }
67- // Awkwardly static. Because the instance is hidden in UsingClientPlatform
68- static std::stringstream ss;
69-};
70-
71-std::stringstream StringStreamLogger::ss;
72-
73-struct Conf : StubConnectionConfiguration
74-{
75- Conf(std::string const& socket)
76- : StubConnectionConfiguration(socket)
77- {
78- }
79- std::shared_ptr<mir::logging::Logger> the_logger() override
80- {
81- return std::make_shared<StringStreamLogger>();
82- }
83+ void log(mir::logging::Severity, std::string const& message, std::string const& component) override
84+ {
85+ out << "[StringStreamLogger] " << component << ": " << message << std::endl;
86+ }
87+
88+ std::stringstream out;
89 };
90
91 struct ClientLogging : ConnectedClientHeadlessServer
92 {
93- UsingClientPlatform<Conf> with_custom_logger;
94- std::stringstream& client_log{StringStreamLogger::ss};
95+ StringStreamLogger logger;
96+
97+ void SetUp() override
98+ {
99+ add_to_environment("MIR_CLIENT_PERF_REPORT", "log");
100+ ConnectedClientHeadlessServer::SetUp();
101+ mir::logging::set_logger(mir::test::fake_shared(logger));
102+ }
103 };
104-
105 } // namespace
106
107 TEST_F(ClientLogging, reports_performance)
108 {
109- TemporaryEnvironmentValue env("MIR_CLIENT_PERF_REPORT", "log");
110- (void)env; // Avoid clang warning/error
111-
112 auto spec = mir_connection_create_spec_for_normal_surface(
113 connection, 123, 456, mir_pixel_format_abgr_8888);
114 ASSERT_THAT(spec, NotNull());
115@@ -94,10 +78,10 @@
116 }
117
118 int reports = 0;
119- while (!client_log.eof())
120+ while (!logger.out.eof())
121 {
122 std::string line;
123- std::getline(client_log, line);
124+ std::getline(logger.out, line);
125 auto perf = line.find(" perf: ");
126 if (perf != line.npos)
127 {
128
129=== renamed file 'include/test/mir_test_framework/stub_client_connection_configuration.h' => 'tests/include/mir_test_framework/stub_client_connection_configuration.h'
130=== renamed file 'include/test/mir_test_framework/using_client_platform.h' => 'tests/include/mir_test_framework/using_client_platform.h'

Subscribers

People subscribed via source and target branches