OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_ | |
6 #define MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_ | |
7 | |
8 #include "mojo/public/c/environment/logger.h" | |
9 #include "mojo/services/log/interfaces/log.mojom.h" | |
10 | |
11 namespace mojo { | |
12 namespace log { | |
13 | |
14 // This is the client library that constructs a MojoLogger that talks to the | |
viettrungluu
2015/11/20 23:21:51
*a* client library, not *the* client library
vardhan
2015/12/02 00:06:13
Done.
| |
15 // Mojo logging service (see ../interfaces/log.mojo). It provides a |MojoLogger| | |
16 // implementation for logging, which you may supply to your |mojo::Environment|. | |
17 // | |
18 // LogClient's life-cycle is similar to |mojo::Environment|. It is only allowed | |
19 // to be instantiated once, and remain so for the duration of its use. The | |
20 // constructor will initialize some internal state and take ownership of the | |
21 // supplied |log_service|. If the pipe to the supplied |log_service| fails, | |
22 // |LogClient| will fallback to using the supplied |fallback_logger|. | |
23 // | |
24 // This class itself is not thread-safe, but the MojoLogger returned by | |
25 // LogClient::GetLogger() is thread-safe for the life time of LogClient. | |
26 // | |
27 // Example on how to replace the Environment's default logger with LogClient: | |
28 // LogPtr log_service; | |
29 // // .. bind log_service to proxy .. | |
30 // LogClient logclient(std::move(log_service), | |
31 // Environment::GetDefaultLogger()); | |
32 // Environment::SetDefaultLogger(LogClient::GetLogger()); | |
viettrungluu
2015/11/20 23:21:51
This example code seems rather bad to me.
In part
vardhan
2015/12/02 00:06:13
I updated the comments to use ApplicationRunner in
| |
33 // // At this point, |MOJO_LOG(..) <<| will start talking to the logging | |
34 // // service. | |
35 class LogClient { | |
36 public: | |
37 LogClient(LogPtr log_service, const MojoLogger* fallback_logger); | |
38 ~LogClient(); | |
39 | |
40 // You can retrieve the logger before any LogClient instance is created, but | |
41 // any uses of the logger may assert-fail. | |
42 static const MojoLogger* GetLogger(); | |
43 }; | |
44 | |
45 } // namespace log | |
46 } // namespace mojo | |
47 | |
48 #endif // MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_ | |
OLD | NEW |