| OLD | NEW |
| 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 Loading... |
| 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 Log("Client connected: " + jid); |
| 47 Log("Client connected: " + username); | |
| 48 } | 48 } |
| 49 | 49 |
| 50 void HostEventLogger::OnClientDisconnected(const std::string& jid) { | 50 void HostEventLogger::OnClientDisconnected(const std::string& jid) { |
| 51 std::string username = jid.substr(0, jid.find('/')); | 51 Log("Client disconnected: " + jid); |
| 52 Log("Client disconnected: " + username); | |
| 53 } | 52 } |
| 54 | 53 |
| 55 void HostEventLogger::OnAccessDenied(const std::string& jid) { | 54 void HostEventLogger::OnAccessDenied(const std::string& jid) { |
| 56 Log("Access denied for client: " + jid); | 55 Log("Access denied for client: " + jid); |
| 57 } | 56 } |
| 58 | 57 |
| 58 void HostEventLogger::OnClientIpAddress(const std::string& jid, |
| 59 const std::string& channel_name, |
| 60 const net::IPEndPoint& end_point) { |
| 61 Log("Channel IP for client: " + jid + " ip='" + end_point.ToString() + |
| 62 "' channel='" + channel_name + "'"); |
| 63 } |
| 64 |
| 59 void HostEventLogger::OnShutdown() { | 65 void HostEventLogger::OnShutdown() { |
| 60 } | 66 } |
| 61 | 67 |
| 62 void HostEventLogger::Log(const std::string& message) { | 68 void HostEventLogger::Log(const std::string& message) { |
| 63 system_event_logger_->Log(message); | 69 system_event_logger_->Log(message); |
| 64 } | 70 } |
| 65 | 71 |
| 66 } // namespace remoting | 72 } // namespace remoting |
| OLD | NEW |