OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/services/log/cpp/log_client.h" | 5 #include "mojo/services/log/cpp/log_client.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 void SetMinimumLogLevel(MojoLogLevel level); | 48 void SetMinimumLogLevel(MojoLogLevel level); |
49 | 49 |
50 private: | 50 private: |
51 const InterfaceHandle<mojo::log::Log> log_interface_; | 51 const InterfaceHandle<mojo::log::Log> log_interface_; |
52 const MojoLogger* const fallback_logger_; | 52 const MojoLogger* const fallback_logger_; |
53 | 53 |
54 MOJO_DISALLOW_COPY_AND_ASSIGN(LogClient); | 54 MOJO_DISALLOW_COPY_AND_ASSIGN(LogClient); |
55 }; | 55 }; |
56 | 56 |
57 LogClient::LogClient(log::LogPtr log, const MojoLogger* fallback_logger) | 57 LogClient::LogClient(log::LogPtr log, const MojoLogger* fallback_logger) |
58 : log_interface_(log.PassInterface()), fallback_logger_(fallback_logger) { | 58 : log_interface_(log.PassInterfaceHandle()), |
| 59 fallback_logger_(fallback_logger) { |
59 assert(log_interface_.is_valid()); | 60 assert(log_interface_.is_valid()); |
60 assert(fallback_logger_); | 61 assert(fallback_logger_); |
61 } | 62 } |
62 | 63 |
63 void LogClient::LogMessage(MojoLogLevel log_level, | 64 void LogClient::LogMessage(MojoLogLevel log_level, |
64 const char* source_file, | 65 const char* source_file, |
65 uint32_t source_line, | 66 uint32_t source_line, |
66 const char* message) const { | 67 const char* message) const { |
67 // We avoid the use of C++ bindings to do interface calls in order to be | 68 // We avoid the use of C++ bindings to do interface calls in order to be |
68 // thread-safe (as of this writing, the bindings are not). Because the | 69 // thread-safe (as of this writing, the bindings are not). Because the |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 162 } |
162 | 163 |
163 void DestroyLogger() { | 164 void DestroyLogger() { |
164 assert(g_log_client); | 165 assert(g_log_client); |
165 delete g_log_client; | 166 delete g_log_client; |
166 g_log_client = nullptr; | 167 g_log_client = nullptr; |
167 } | 168 } |
168 | 169 |
169 } // namespace log | 170 } // namespace log |
170 } // namespace mojo | 171 } // namespace mojo |
OLD | NEW |