~alan-griffiths/mir/frontend-ConnectorReport-enablement

« back to all changes in this revision

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

  • Committer: Alan Griffiths
  • Date: 2013-09-27 16:27:29 UTC
  • Revision ID: alan@octopull.co.uk-20130927162729-0zh00ub3z5aj6r96
logging::ConnectorReport

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Alan Griffiths <alan@octopull.co.uk>
 
17
 */
 
18
 
 
19
#include "mir/logging/connector_report.h"
 
20
 
 
21
#include "mir/logging/logger.h"
 
22
 
 
23
#include <boost/exception/diagnostic_information.hpp>
 
24
 
 
25
#include <sstream>
 
26
#include <thread>
 
27
 
 
28
namespace ml = mir::logging;
 
29
 
 
30
namespace
 
31
{
 
32
char const* const component = "frontend::SessionMediator";
 
33
}
 
34
 
 
35
ml::ConnectorReport::ConnectorReport(std::shared_ptr<Logger> const& log) :
 
36
    logger(log)
 
37
{
 
38
}
 
39
 
 
40
void ml::ConnectorReport::thread_start()
 
41
{
 
42
    std::stringstream ss;
 
43
    ss << "thread (" << std::this_thread::get_id() << ") started.";
 
44
    logger->log<Logger::informational>(ss.str(), component);
 
45
}
 
46
 
 
47
void ml::ConnectorReport::thread_end()
 
48
{
 
49
    std::stringstream ss;
 
50
    ss << "thread (" << std::this_thread::get_id() << ") ended.";
 
51
    logger->log<Logger::informational>(ss.str(), component);
 
52
}
 
53
 
 
54
void ml::ConnectorReport::starting_threads(int count)
 
55
{
 
56
    std::stringstream ss;
 
57
    ss << "Starting " << count << ") ended.";
 
58
    logger->log<Logger::informational>(ss.str(), component);
 
59
}
 
60
 
 
61
void ml::ConnectorReport::stopping_threads(int count)
 
62
{
 
63
    std::stringstream ss;
 
64
    ss << "Stopping " << count << " threads.";
 
65
    logger->log<Logger::informational>(ss.str(), component);
 
66
}
 
67
 
 
68
void ml::ConnectorReport::creating_session_for(int socket_handle)
 
69
{
 
70
    std::stringstream ss;
 
71
    ss << "Creating session for socket " << socket_handle;
 
72
    logger->log<Logger::informational>(ss.str(), component);
 
73
}
 
74
 
 
75
void ml::ConnectorReport::creating_socket_pair(int server_handle, int client_handle)
 
76
{
 
77
    std::stringstream ss;
 
78
    ss << "Creating socket pair (server=" << server_handle << ", client=" << client_handle << ").";
 
79
    logger->log<Logger::informational>(ss.str(), component);
 
80
}
 
81
 
 
82
void ml::ConnectorReport::listening_on(std::string const& endpoint)
 
83
{
 
84
    std::stringstream ss;
 
85
    ss << "Listening on endpoint: " << endpoint;
 
86
    logger->log<Logger::informational>(ss.str(), component);
 
87
}
 
88
 
 
89
void ml::ConnectorReport::error(std::exception const& error)
 
90
{
 
91
    std::stringstream ss;
 
92
    ss << "Error: " << boost::diagnostic_information(error) << std::endl;
 
93
 
 
94
    logger->log<ml::Logger::warning>(ss.str(), component);
 
95
}
 
96
 
 
97
 
 
98