Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: mojo/services/log/cpp/log_client.h

Issue 2011593002: Make RunApplication() return a MojoResult and TerminateApplication() take one. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This is a client library that constructs a MojoLogger that can talk to a 5 // This is a client library that constructs a MojoLogger that can talk to a
6 // Mojo logging service (see ../interfaces/log.mojo). It provides a |MojoLogger| 6 // Mojo logging service (see ../interfaces/log.mojo). It provides a |MojoLogger|
7 // implementation which can be used as the default environment logger. 7 // implementation which can be used as the default environment logger.
8 // 8 //
9 // Example application that uses this log client to talk to the log service: 9 // Example application that uses this log client to talk to the log service:
10 // 10 //
11 // class MyApp : public mojo::ApplicationImplBase { 11 // class MyApp : public mojo::ApplicationImplBase {
12 // public: 12 // public:
13 // void OnInitialize() override { 13 // void OnInitialize() override {
14 // LogPtr log; 14 // LogPtr log;
15 // mojo::ConnectToService(shell(), "mojo:log", &log); 15 // mojo::ConnectToService(shell(), "mojo:log", &log);
16 // mojo::log::InitializeLogger(std::move(log), 16 // mojo::log::InitializeLogger(std::move(log),
17 // mojo::Environment::GetDefaultLogger()); 17 // mojo::Environment::GetDefaultLogger());
18 // mojo::Environment::SetDefaultLogger(mojo::log::GetLogger()); 18 // mojo::Environment::SetDefaultLogger(mojo::log::GetLogger());
19 // } 19 // }
20 // 20 //
21 // void OnQuit() override { 21 // void OnQuit() override {
22 // mojo::log::DestroyLogger(); 22 // mojo::log::DestroyLogger();
23 // } 23 // }
24 // }; 24 // };
25 // 25 //
26 // MojoResult MojoMain(MojoHandle app_request) { 26 // MojoResult MojoMain(MojoHandle app_request) {
27 // MyApp app; 27 // MyApp app;
28 // mojo::RunApplication(&app); 28 // return mojo::RunApplication(&app);
29 // return MOJO_RESULT_OK;
30 // } 29 // }
31 30
32 #ifndef MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_ 31 #ifndef MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_
33 #define MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_ 32 #define MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_
34 33
35 #include "mojo/public/c/environment/logger.h" 34 #include "mojo/public/c/environment/logger.h"
36 #include "mojo/services/log/interfaces/log.mojom.h" 35 #include "mojo/services/log/interfaces/log.mojom.h"
37 36
38 namespace mojo { 37 namespace mojo {
39 namespace log { 38 namespace log {
40 39
41 // Constructs a MojoLogger (which can be retrieved with |GetLogger()|) that 40 // Constructs a MojoLogger (which can be retrieved with |GetLogger()|) that
42 // talks to the provided log service. |fallback_logger| must be non-null and 41 // talks to the provided log service. |fallback_logger| must be non-null and
43 // will be used if the provided |log_service| fails. The constructed MojoLogger 42 // will be used if the provided |log_service| fails. The constructed MojoLogger
44 // may also call into |fallback_logger|'s [Set|Get]MinimumLogLevel functions to 43 // may also call into |fallback_logger|'s [Set|Get]MinimumLogLevel functions to
45 // keep the minimum levels consistent. 44 // keep the minimum levels consistent.
46 void InitializeLogger(LogPtr log_service, const MojoLogger* fallback_logger); 45 void InitializeLogger(LogPtr log_service, const MojoLogger* fallback_logger);
47 46
48 // Must be called after |InitializeLogger()| and before |DestroyLogger()|. The 47 // Must be called after |InitializeLogger()| and before |DestroyLogger()|. The
49 // returned MojoLogger is thread-safe. 48 // returned MojoLogger is thread-safe.
50 const MojoLogger* GetLogger(); 49 const MojoLogger* GetLogger();
51 50
52 void DestroyLogger(); 51 void DestroyLogger();
53 52
54 } // namespace log 53 } // namespace log
55 } // namespace mojo 54 } // namespace mojo
56 55
57 #endif // MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_ 56 #endif // MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/utility/lib/run_loop.cc ('k') | services/test_service/test_request_tracker_application.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698