Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: remoting/host/host_event_logger_posix.cc

Issue 9727005: Log connection type to syslogs and to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/client_session.cc ('k') | remoting/host/host_event_logger_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/host_event_logger.h" 5 #include "remoting/host/host_event_logger.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
11 #include "remoting/host/chromoting_host.h" 11 #include "remoting/host/chromoting_host.h"
12 #include "remoting/host/host_status_observer.h" 12 #include "remoting/host/host_status_observer.h"
13 #include "remoting/protocol/transport.h"
13 14
14 // Included here, since the #define for LOG_USER in syslog.h conflicts with the 15 // Included here, since the #define for LOG_USER in syslog.h conflicts with the
15 // constants in base/logging.h, and this source file should use the version in 16 // constants in base/logging.h, and this source file should use the version in
16 // syslog.h. 17 // syslog.h.
17 #include <syslog.h> 18 #include <syslog.h>
18 19
19 namespace remoting { 20 namespace remoting {
20 21
21 namespace { 22 namespace {
22 23
23 class HostEventLoggerPosix : public HostEventLogger, public HostStatusObserver { 24 class HostEventLoggerPosix : public HostEventLogger, public HostStatusObserver {
24 public: 25 public:
25 HostEventLoggerPosix(ChromotingHost* host, 26 HostEventLoggerPosix(ChromotingHost* host,
26 const std::string& application_name); 27 const std::string& application_name);
27 28
28 virtual ~HostEventLoggerPosix(); 29 virtual ~HostEventLoggerPosix();
29 30
30 // HostStatusObserver implementation. These methods will be called from the 31 // HostStatusObserver implementation. These methods will be called from the
31 // network thread. 32 // network thread.
32 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; 33 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
33 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; 34 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
34 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; 35 virtual void OnAccessDenied(const std::string& jid) OVERRIDE;
35 virtual void OnClientRouteChange( 36 virtual void OnClientRouteChange(
36 const std::string& jid, 37 const std::string& jid,
37 const std::string& channel_name, 38 const std::string& channel_name,
38 const net::IPEndPoint& remote_end_point, 39 const protocol::TransportRoute& route) OVERRIDE;
39 const net::IPEndPoint& local_end_point) OVERRIDE;
40 virtual void OnShutdown() OVERRIDE; 40 virtual void OnShutdown() OVERRIDE;
41 41
42 private: 42 private:
43 void Log(const std::string& message); 43 void Log(const std::string& message);
44 44
45 scoped_refptr<ChromotingHost> host_; 45 scoped_refptr<ChromotingHost> host_;
46 std::string application_name_; 46 std::string application_name_;
47 47
48 DISALLOW_COPY_AND_ASSIGN(HostEventLoggerPosix); 48 DISALLOW_COPY_AND_ASSIGN(HostEventLoggerPosix);
49 }; 49 };
(...skipping 21 matching lines...) Expand all
71 Log("Client disconnected: " + jid); 71 Log("Client disconnected: " + jid);
72 } 72 }
73 73
74 void HostEventLoggerPosix::OnAccessDenied(const std::string& jid) { 74 void HostEventLoggerPosix::OnAccessDenied(const std::string& jid) {
75 Log("Access denied for client: " + jid); 75 Log("Access denied for client: " + jid);
76 } 76 }
77 77
78 void HostEventLoggerPosix::OnClientRouteChange( 78 void HostEventLoggerPosix::OnClientRouteChange(
79 const std::string& jid, 79 const std::string& jid,
80 const std::string& channel_name, 80 const std::string& channel_name,
81 const net::IPEndPoint& remote_end_point, 81 const protocol::TransportRoute& route) {
82 const net::IPEndPoint& local_end_point) {
83 Log(base::StringPrintf( 82 Log(base::StringPrintf(
84 "Channel IP for client: %s ip='%s' host_ip='%s' channel='%s'", 83 "Channel IP for client: %s ip='%s' host_ip='%s' channel='%s' "
85 jid.c_str(), remote_end_point.ToString().c_str(), 84 "connection='%s'",
86 local_end_point.ToString().c_str(), channel_name.c_str())); 85 jid.c_str(), route.remote_address.ToString().c_str(),
86 route.local_address.ToString().c_str(), channel_name.c_str(),
87 protocol::TransportRoute::GetTypeString(route.type).c_str()));
87 } 88 }
88 89
89 void HostEventLoggerPosix::OnShutdown() { 90 void HostEventLoggerPosix::OnShutdown() {
90 } 91 }
91 92
92 void HostEventLoggerPosix::Log(const std::string& message) { 93 void HostEventLoggerPosix::Log(const std::string& message) {
93 syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str()); 94 syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str());
94 } 95 }
95 96
96 // static 97 // static
97 scoped_ptr<HostEventLogger> HostEventLogger::Create( 98 scoped_ptr<HostEventLogger> HostEventLogger::Create(
98 ChromotingHost* host, const std::string& application_name) { 99 ChromotingHost* host, const std::string& application_name) {
99 return scoped_ptr<HostEventLogger>( 100 return scoped_ptr<HostEventLogger>(
100 new HostEventLoggerPosix(host, application_name)); 101 new HostEventLoggerPosix(host, application_name));
101 } 102 }
102 103
103 } // namespace remoting 104 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_session.cc ('k') | remoting/host/host_event_logger_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698