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

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

Issue 9288040: Log client IP addresses to syslog in Me2Me host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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
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 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <syslog.h> 8 #include <syslog.h>
9 // Following defines from syslog.h conflict with constants in 9 // Following defines from syslog.h conflict with constants in
10 // base/logging.h. 10 // base/logging.h.
11 #undef LOG_INFO 11 #undef LOG_INFO
12 #undef LOG_WARNING 12 #undef LOG_WARNING
13 #endif // defined(OS_LINUX) 13 #endif // defined(OS_LINUX)
14 14
15 #include "net/base/ip_endpoint.h"
15 #include "remoting/host/chromoting_host.h" 16 #include "remoting/host/chromoting_host.h"
16 #include "remoting/host/system_event_logger.h" 17 #include "remoting/host/system_event_logger.h"
17 18
18 namespace { 19 namespace {
19 20
20 void Log(const std::string& message) { 21 void Log(const std::string& message) {
21 // TODO(lambroslambrou): Refactor this part into platform-specific classes. 22 // TODO(lambroslambrou): Refactor this part into platform-specific classes.
22 #if defined(OS_LINUX) 23 #if defined(OS_LINUX)
23 syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str()); 24 syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str());
24 #endif 25 #endif
(...skipping 11 matching lines...) Expand all
36 openlog("chromoting_host", 0, LOG_USER); 37 openlog("chromoting_host", 0, LOG_USER);
37 #endif 38 #endif
38 host_->AddStatusObserver(this); 39 host_->AddStatusObserver(this);
39 } 40 }
40 41
41 HostEventLogger::~HostEventLogger() { 42 HostEventLogger::~HostEventLogger() {
42 host_->RemoveStatusObserver(this); 43 host_->RemoveStatusObserver(this);
43 } 44 }
44 45
45 void HostEventLogger::OnClientAuthenticated(const std::string& jid) { 46 void HostEventLogger::OnClientAuthenticated(const std::string& jid) {
46 std::string username = jid.substr(0, jid.find('/')); 47 std::string username = jid.substr(0, jid.find('/'));
Sergey Ulanov 2012/01/26 00:48:56 I don't think we should strip resourceId from the
Lambros 2012/01/26 19:40:14 Done.
47 Log("Client connected: " + username); 48 Log("Client connected: " + username);
48 } 49 }
49 50
50 void HostEventLogger::OnClientDisconnected(const std::string& jid) { 51 void HostEventLogger::OnClientDisconnected(const std::string& jid) {
51 std::string username = jid.substr(0, jid.find('/')); 52 std::string username = jid.substr(0, jid.find('/'));
Sergey Ulanov 2012/01/26 00:48:56 same here
Lambros 2012/01/26 19:40:14 Done.
52 Log("Client disconnected: " + username); 53 Log("Client disconnected: " + username);
53 } 54 }
54 55
55 void HostEventLogger::OnAccessDenied(const std::string& jid) { 56 void HostEventLogger::OnAccessDenied(const std::string& jid) {
56 Log("Access denied for client: " + jid); 57 Log("Access denied for client: " + jid);
57 } 58 }
58 59
60 void HostEventLogger::OnClientIpAddress(const std::string& jid,
61 const std::string& channel_name,
62 const net::IPEndPoint& end_point) {
63 Log("Channel IP for client: " + jid + " ip='" + end_point.ToString() +
64 "' channel='" + channel_name + "'");
65 }
66
59 void HostEventLogger::OnShutdown() { 67 void HostEventLogger::OnShutdown() {
60 } 68 }
61 69
62 void HostEventLogger::Log(const std::string& message) { 70 void HostEventLogger::Log(const std::string& message) {
63 system_event_logger_->Log(message); 71 system_event_logger_->Log(message);
64 } 72 }
65 73
66 } // namespace remoting 74 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698