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

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

Issue 1447273002: Mojo Log service and a thread-safe client library. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: make min log level consistent with fallback logger, fix thread-safety, address trung's other commen… Created 5 years 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
(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 // 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|
7 // implementation which can be used as the default environment logger.
8 //
9 // Example application that uses this log client to talk to the log service:
10 //
11 // class MyDelegate : public mojo::ApplicationDelegate {
12 // public:
13 // void Initialize(mojo::ApplicationImpl* app) override {
14 // LogPtr log;
15 // app->ConnectToService("mojo:log", &log);
16 // mojo::log::InitializeLogger(std::move(log),
17 // ApplicationRunner::GetDefaultLogger());
18 // mojo::ApplicationRunner::SetDefaultLogger(mojo::log::GetLogger());
19 // }
20 //
21 // void Quit() {
22 // mojo::log::DestroyLogger();
23 // }
24 // };
25 //
26 // MojoResult MojoMain(MojoHandle app_request) {
27 // mojo::ApplicationRunner runner(new MyDelegate);
28 // return runner.Run(app_request);
29 // }
30
31 #ifndef MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_
32 #define MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_
33
34 #include "mojo/public/c/environment/logger.h"
35 #include "mojo/services/log/interfaces/log.mojom.h"
36
37 namespace mojo {
38 namespace log {
39
40 // Constructs a MojoLogger (which can be retrieved with |GetLogger()|) that
41 // talks to the provided log service. |fallback_logger| will be used if logging
42 // to the provided |log_service| fails, and so must be non-null and thread-safe.
viettrungluu 2015/12/17 18:34:39 "and thread-safe" is redundant, I guess.
vardhan 2015/12/17 23:35:42 Done.
43 // The constructed MojoLogger may also call into |fallback_logger|'s
44 // [Set|Get]MinimumLogLevel functions to keep the minimum levels consistent.
45 void InitializeLogger(LogPtr log_service, const MojoLogger* fallback_logger);
46
47 // Must be called after |InitializeLogger()| and before |DestroyLogger()|. The
48 // returned MojoLogger is thread-safe.
49 const MojoLogger* GetLogger();
50
51 void DestroyLogger();
52
53 } // namespace log
54 } // namespace mojo
55
56 #endif // MOJO_SERVICES_LOG_CPP_LOG_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698