summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 03:18:38 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 03:18:38 +0000
commita495b97dc886764be083976ca94e51116ed0b34e (patch)
treedbc9929d6a806bddb35f2b923ceb8048ddb3b7ee /remoting
parent93c1f78d4b36ff960b34210f62eb6c447d22e60d (diff)
downloadchromium_src-a495b97dc886764be083976ca94e51116ed0b34e.zip
chromium_src-a495b97dc886764be083976ca94e51116ed0b34e.tar.gz
chromium_src-a495b97dc886764be083976ca94e51116ed0b34e.tar.bz2
Refactor system event logging into platform-specific classes.
Currently only Linux, as remoting_me2me_host is a Linux-specific GYP target. BUG=109682 TEST=Manual Review URL: http://codereview.chromium.org/9174022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/host_event_logger.cc11
-rw-r--r--remoting/host/host_event_logger.h8
-rw-r--r--remoting/host/remoting_me2me_host.cc5
-rw-r--r--remoting/host/system_event_logger.h27
-rw-r--r--remoting/host/system_event_logger_linux.cc38
-rw-r--r--remoting/remoting.gyp2
6 files changed, 87 insertions, 4 deletions
diff --git a/remoting/host/host_event_logger.cc b/remoting/host/host_event_logger.cc
index f8f6d57..ca8e49a 100644
--- a/remoting/host/host_event_logger.cc
+++ b/remoting/host/host_event_logger.cc
@@ -13,6 +13,7 @@
#endif // defined(OS_LINUX)
#include "remoting/host/chromoting_host.h"
+#include "remoting/host/system_event_logger.h"
namespace {
@@ -27,8 +28,10 @@ void Log(const std::string& message) {
namespace remoting {
-HostEventLogger::HostEventLogger(ChromotingHost* host)
- : host_(host) {
+HostEventLogger::HostEventLogger(ChromotingHost* host,
+ const std::string& application_name)
+ : host_(host),
+ system_event_logger_(SystemEventLogger::Create(application_name)) {
#if defined(OS_LINUX)
openlog("chromoting_host", 0, LOG_USER);
#endif
@@ -56,4 +59,8 @@ void HostEventLogger::OnAccessDenied(const std::string& jid) {
void HostEventLogger::OnShutdown() {
}
+void HostEventLogger::Log(const std::string& message) {
+ system_event_logger_->Log(message);
+}
+
} // namespace remoting
diff --git a/remoting/host/host_event_logger.h b/remoting/host/host_event_logger.h
index 0b849ef..2ca9afc 100644
--- a/remoting/host/host_event_logger.h
+++ b/remoting/host/host_event_logger.h
@@ -7,17 +7,20 @@
#include <string>
+#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "remoting/host/host_status_observer.h"
namespace remoting {
class ChromotingHost;
+class SystemEventLogger;
class HostEventLogger : public HostStatusObserver {
public:
- HostEventLogger(ChromotingHost* host);
+ HostEventLogger(ChromotingHost* host, const std::string& application_name);
virtual ~HostEventLogger();
// HostStatusObserver implementation. These methods will be called from the
@@ -28,7 +31,10 @@ class HostEventLogger : public HostStatusObserver {
virtual void OnShutdown() OVERRIDE;
private:
+ void Log(const std::string& message);
+
scoped_refptr<ChromotingHost> host_;
+ scoped_ptr<SystemEventLogger> system_event_logger_;
DISALLOW_COPY_AND_ASSIGN(HostEventLogger);
};
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 1e4c4ae..6cb5565 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -40,6 +40,9 @@
namespace {
+// This is used for tagging system event logs.
+const char kApplicationName[] = "remoting_me2me_host";
+
// These are used for parsing the config-file locations from the command line,
// and for defining the default locations if the switches are not present.
const char kAuthConfigSwitchName[] = "auth-config";
@@ -174,7 +177,7 @@ class HostProcess {
new HeartbeatSender(host_id_, signal_strategy_.get(), &key_pair_));
log_to_server_.reset(new LogToServer(host_, signal_strategy_.get()));
- host_event_logger_.reset(new HostEventLogger(host_));
+ host_event_logger_.reset(new HostEventLogger(host_, kApplicationName));
host_->Start();
diff --git a/remoting/host/system_event_logger.h b/remoting/host/system_event_logger.h
new file mode 100644
index 0000000..ee894ee
--- /dev/null
+++ b/remoting/host/system_event_logger.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_SYSTEM_EVENT_LOGGER_H_
+#define REMOTING_HOST_SYSTEM_EVENT_LOGGER_H_
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+
+namespace remoting {
+
+class SystemEventLogger {
+ public:
+ virtual ~SystemEventLogger() {}
+
+ virtual void Log(const std::string& message) = 0;
+
+ // Create an event-logger that tags log messages with |application_name|.
+ static scoped_ptr<SystemEventLogger> Create(
+ const std::string& application_name);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_SYSTEM_EVENT_LOGGER_H_
diff --git a/remoting/host/system_event_logger_linux.cc b/remoting/host/system_event_logger_linux.cc
new file mode 100644
index 0000000..4518d5d
--- /dev/null
+++ b/remoting/host/system_event_logger_linux.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/system_event_logger.h"
+
+#include <syslog.h>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+
+namespace remoting {
+
+namespace {
+
+class SystemEventLoggerLinux : public SystemEventLogger {
+ public:
+ SystemEventLoggerLinux(const std::string& application_name) {
+ openlog(application_name.c_str(), 0, LOG_USER);
+ }
+
+ virtual void Log(const std::string& message) OVERRIDE {
+ syslog(LOG_USER | LOG_NOTICE, "%s", message.c_str());
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(SystemEventLoggerLinux);
+};
+
+} // namespace
+
+// static
+scoped_ptr<SystemEventLogger> SystemEventLogger::Create(
+ const std::string& application_name) {
+ return scoped_ptr<SystemEventLogger>(
+ new SystemEventLoggerLinux(application_name));
+}
+
+} // namespace remoting
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index b3d9694..d1991b8 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -220,6 +220,8 @@
'host/host_event_logger.cc',
'host/host_event_logger.h',
'host/remoting_me2me_host.cc',
+ 'host/system_event_logger_linux.cc',
+ 'host/system_event_logger.h',
],
}, # end of target 'remoting_me2me_host'