OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_BASE_LOGGER_H_ | |
6 #define REMOTING_BASE_LOGGER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/task.h" | |
10 | |
11 class MessageLoop; | |
12 | |
13 namespace remoting { | |
14 | |
15 class Logger { | |
16 public: | |
17 Logger(); | |
18 virtual ~Logger(); | |
19 | |
20 void SetThread(MessageLoop* message_loop) { | |
21 message_loop_ = message_loop; | |
22 } | |
23 | |
24 void Log(logging::LogSeverity severity, const char* format, ...); | |
25 void VLog(int verboselevel, const char* format, ...); | |
26 | |
27 void va_Log(logging::LogSeverity severity, const char* format, va_list ap); | |
28 void va_VLog(int verboselevel, const char* format, va_list ap); | |
29 | |
30 protected: | |
31 // Log to the UI after switching to the correct thread. | |
32 void LogToUI_CorrectThread(const std::string& message); | |
33 | |
34 virtual void LogToUI(const std::string& message); | |
35 | |
36 static const char* const log_severity_names[]; | |
37 | |
38 // We want all the log messages to be posted to the same thread so that: | |
39 // (1) they are queued up in-order, and | |
40 // (2) we don't try to update the log at the same time from multiple threads. | |
41 MessageLoop* message_loop_; | |
42 | |
43 private: | |
44 DISALLOW_COPY_AND_ASSIGN(Logger); | |
45 }; | |
46 | |
47 } // namespace remoting | |
48 | |
49 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::Logger); | |
50 | |
51 #endif // REMOTING_BASE_LOGGER_H_ | |
OLD | NEW |