diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 23:05:01 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 23:05:01 +0000 |
commit | 9a37fdf2a4314bf49c003a8f126f06751ba1ba55 (patch) | |
tree | 4659ba663a7c6eeaf125b63db2311f0787a78a34 /remoting/base | |
parent | 02712128820af52b4ed31830fe950d64102cf954 (diff) | |
download | chromium_src-9a37fdf2a4314bf49c003a8f126f06751ba1ba55.zip chromium_src-9a37fdf2a4314bf49c003a8f126f06751ba1ba55.tar.gz chromium_src-9a37fdf2a4314bf49c003a8f126f06751ba1ba55.tar.bz2 |
Conenct Chromoting plugin debug log to JS UI.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7262015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91779 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r-- | remoting/base/logger.cc | 50 | ||||
-rw-r--r-- | remoting/base/logger.h | 34 |
2 files changed, 84 insertions, 0 deletions
diff --git a/remoting/base/logger.cc b/remoting/base/logger.cc new file mode 100644 index 0000000..f4def7b --- /dev/null +++ b/remoting/base/logger.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2011 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/base/logger.h" + +#include <stdarg.h> // va_list + +#include "base/stringprintf.h" + +namespace remoting { + +// Copied from base/logging.cc. +const char* const Logger::log_severity_names[logging::LOG_NUM_SEVERITIES] = { + "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" }; + +Logger::Logger() { +} + +Logger::~Logger() { +} + +void Logger::Log(logging::LogSeverity severity, const char* format, ...) { + va_list ap; + va_start(ap, format); + va_Log(severity, format, ap); + va_end(ap); +} + +void Logger::VLog(int verboselevel, const char* format, ...) { + va_list ap; + va_start(ap, format); + va_VLog(verboselevel, format, ap); + va_end(ap); +} + +void Logger::va_Log(logging::LogSeverity severity, + const char* format, va_list ap) { + std::string message; + base::StringAppendV(&message, format, ap); + logging::LogMessage(__FILE__, __LINE__, severity).stream() << message; +} + +void Logger::va_VLog(int verboselevel, const char* format, va_list ap) { + std::string message; + base::StringAppendV(&message, format, ap); + VLOG(verboselevel) << message; +} + +} // namespace remoting diff --git a/remoting/base/logger.h b/remoting/base/logger.h new file mode 100644 index 0000000..1022e4f --- /dev/null +++ b/remoting/base/logger.h @@ -0,0 +1,34 @@ +// Copyright (c) 2011 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_BASE_LOGGER_H_ +#define REMOTING_BASE_LOGGER_H_ + +#include "base/basictypes.h" +#include "base/logging.h" + +namespace remoting { + +class Logger { + public: + Logger(); + virtual ~Logger(); + + void Log(logging::LogSeverity severity, const char* format, ...); + void VLog(int verboselevel, const char* format, ...); + + virtual void va_Log(logging::LogSeverity severity, + const char* format, va_list ap); + virtual void va_VLog(int verboselevel, const char* format, va_list ap); + + protected: + static const char* const log_severity_names[]; + + private: + DISALLOW_COPY_AND_ASSIGN(Logger); +}; + +} // namespace remoting + +#endif // REMOTING_BASE_LOGGER_H_ |