| 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/plugin/host_log_handler.h" | 5 #include "remoting/host/plugin/host_log_handler.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "remoting/base/logging.h" |
| 8 #include "remoting/base/util.h" | 9 #include "remoting/base/util.h" |
| 9 #include "remoting/host/plugin/host_script_object.h" | 10 #include "remoting/host/plugin/host_script_object.h" |
| 10 | 11 |
| 11 namespace remoting { | 12 namespace remoting { |
| 12 | 13 |
| 13 // Records whether or not we have a scriptable object registered for logging. | 14 // Records whether or not we have a scriptable object registered for logging. |
| 14 // This is set inside the lock, but is read (in LogToUI) outside of a lock so | 15 // This is set inside the lock, but is read (in LogToUI) outside of a lock so |
| 15 // that we don't needlessly slow down the system when we log. | 16 // that we don't needlessly slow down the system when we log. |
| 16 static bool g_has_logging_scriptable_object = false; | 17 static bool g_has_logging_scriptable_object = false; |
| 17 | 18 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 // to register it twice. | 31 // to register it twice. |
| 31 static bool g_has_registered_log_handler = false; | 32 static bool g_has_registered_log_handler = false; |
| 32 | 33 |
| 33 // static | 34 // static |
| 34 void HostLogHandler::RegisterLogMessageHandler() { | 35 void HostLogHandler::RegisterLogMessageHandler() { |
| 35 base::AutoLock lock(g_logging_lock.Get()); | 36 base::AutoLock lock(g_logging_lock.Get()); |
| 36 | 37 |
| 37 if (g_has_registered_log_handler) | 38 if (g_has_registered_log_handler) |
| 38 return; | 39 return; |
| 39 | 40 |
| 40 LOG(INFO) << "Registering global log handler"; | 41 HOST_LOG << "Registering global log handler"; |
| 41 | 42 |
| 42 // Record previous handler so we can call it in a chain. | 43 // Record previous handler so we can call it in a chain. |
| 43 g_logging_old_handler = logging::GetLogMessageHandler(); | 44 g_logging_old_handler = logging::GetLogMessageHandler(); |
| 44 | 45 |
| 45 // Set up log message handler. | 46 // Set up log message handler. |
| 46 // This is not thread-safe so we need it within our lock. | 47 // This is not thread-safe so we need it within our lock. |
| 47 // Note that this will not log anything until a scriptable object instance | 48 // Note that this will not log anything until a scriptable object instance |
| 48 // has been created to handle the log message display. | 49 // has been created to handle the log message display. |
| 49 logging::SetLogMessageHandler(&LogToUI); | 50 logging::SetLogMessageHandler(&LogToUI); |
| 50 g_has_registered_log_handler = true; | 51 g_has_registered_log_handler = true; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 114 } |
| 114 | 115 |
| 115 // Call the next log handler in the chain. | 116 // Call the next log handler in the chain. |
| 116 if (g_logging_old_handler) | 117 if (g_logging_old_handler) |
| 117 return (g_logging_old_handler)(severity, file, line, message_start, str); | 118 return (g_logging_old_handler)(severity, file, line, message_start, str); |
| 118 | 119 |
| 119 return false; | 120 return false; |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace remoting | 123 } // namespace remoting |
| OLD | NEW |