~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/server/logging/default_configuration.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
Import upstream version 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2013 Canonical Ltd.
 
2
 * Copyright © 2013-2014 Canonical Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License version 3,
16
16
 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17
17
 */
18
18
 
 
19
#include "mir/logging/logger.h"
 
20
#include "mir/logging/glog_logger.h"
19
21
#include "mir/default_server_configuration.h"
20
 
#include "mir/abnormal_exit.h"
21
 
 
22
 
#include "connector_report.h"
23
 
#include "display_report.h"
24
 
#include "session_mediator_report.h"
25
 
 
26
 
#include "mir/graphics/null_display_report.h"
27
 
#include "compositor_report.h"
28
 
 
29
 
using namespace mir;
30
 
namespace mf = mir::frontend;
31
 
namespace mg = mir::graphics;
 
22
#include "mir/options/default_configuration.h"
 
23
#include "mir/logging/dumb_console_logger.h"
 
24
 
32
25
namespace ml = mir::logging;
33
 
namespace ms = mir::scene;
34
 
 
35
 
auto mir::DefaultServerConfiguration::the_connector_report()
36
 
    -> std::shared_ptr<mf::ConnectorReport>
37
 
{
38
 
    return connector_report([this]
39
 
        () -> std::shared_ptr<mf::ConnectorReport>
40
 
        {
41
 
            auto opt = the_options()->get<std::string>(connector_report_opt);
42
 
 
43
 
            if (opt == log_opt_value)
44
 
            {
45
 
                return std::make_shared<ml::ConnectorReport>(the_logger());
46
 
            }
47
 
            else if (opt == off_opt_value)
48
 
            {
49
 
                return std::make_shared<mf::NullConnectorReport>();
50
 
            }
51
 
            else
52
 
            {
53
 
                throw AbnormalExit(std::string("Invalid ") + connector_report_opt + " option: " + opt +
54
 
                    " (valid options are: \"" + off_opt_value + "\" and \"" + log_opt_value + "\")");
55
 
            }
56
 
        });
57
 
}
58
 
 
59
 
std::shared_ptr<mg::DisplayReport> mir::DefaultServerConfiguration::the_display_report()
60
 
{
61
 
    return display_report(
62
 
        [this]() -> std::shared_ptr<graphics::DisplayReport>
63
 
        {
64
 
            if (the_options()->get<std::string>(display_report_opt) == log_opt_value)
65
 
            {
66
 
                return std::make_shared<ml::DisplayReport>(the_logger());
67
 
            }
68
 
            else
69
 
            {
70
 
                return std::make_shared<mg::NullDisplayReport>();
71
 
            }
72
 
        });
73
 
}
74
 
 
75
 
std::shared_ptr<compositor::CompositorReport>
76
 
DefaultServerConfiguration::the_compositor_report()
77
 
{
78
 
    return compositor_report(
79
 
        [this]() -> std::shared_ptr<compositor::CompositorReport>
80
 
        {
81
 
            if (the_options()->get<std::string>(compositor_report_opt) == log_opt_value)
82
 
            {
83
 
                return std::make_shared<ml::CompositorReport>(
84
 
                    the_logger(), the_clock());
85
 
            }
86
 
            else
87
 
            {
88
 
                return std::make_shared<compositor::NullCompositorReport>();
89
 
            }
90
 
        });
91
 
}
92
 
 
93
 
std::shared_ptr<mf::SessionMediatorReport>
94
 
mir::DefaultServerConfiguration::the_session_mediator_report()
95
 
{
96
 
    return session_mediator_report(
97
 
        [this]() -> std::shared_ptr<mf::SessionMediatorReport>
98
 
        {
99
 
            if (the_options()->get<std::string>(session_mediator_report_opt) == log_opt_value)
100
 
            {
101
 
                return std::make_shared<ml::SessionMediatorReport>(the_logger());
102
 
            }
103
 
            else
104
 
            {
105
 
                return std::make_shared<mf::NullSessionMediatorReport>();
106
 
            }
107
 
        });
108
 
}
 
26
 
 
27
auto mir::DefaultServerConfiguration::the_logger()
 
28
    -> std::shared_ptr<ml::Logger>
 
29
{
 
30
    return logger(
 
31
        [this]() -> std::shared_ptr<ml::Logger>
 
32
        {
 
33
            if (the_options()->is_set(options::glog))
 
34
            {
 
35
                return std::make_shared<ml::GlogLogger>(
 
36
                    "mir",
 
37
                    the_options()->get<int>(options::glog_stderrthreshold),
 
38
                    the_options()->get<int>(options::glog_minloglevel),
 
39
                    the_options()->get<std::string>(options::glog_log_dir));
 
40
            }
 
41
            else
 
42
            {
 
43
                return std::make_shared<ml::DumbConsoleLogger>();
 
44
            }
 
45
        });
 
46
}
 
47
 
 
48