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

Side by Side Diff: mojo/environment/default_logger_impl.cc

Issue 1765243002: Remove Mojo bindings environment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « mojo/environment/default_logger_impl.h ('k') | mojo/environment/default_run_loop_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 #include "mojo/environment/default_logger_impl.h"
6
7 #include <stdint.h>
8
9 #include "base/logging.h"
10 #include "base/macros.h"
11
12 namespace mojo {
13 namespace internal {
14 namespace {
15
16 // We rely on log levels being the same numerically:
17 static_assert(logging::LOG_VERBOSE == MOJO_LOG_LEVEL_VERBOSE,
18 "verbose log level value mismatch");
19 static_assert(logging::LOG_INFO == MOJO_LOG_LEVEL_INFO,
20 "info log level value mismatch");
21 static_assert(logging::LOG_WARNING == MOJO_LOG_LEVEL_WARNING,
22 "warning log level value mismatch");
23 static_assert(logging::LOG_ERROR == MOJO_LOG_LEVEL_ERROR,
24 "error log level value mismatch");
25 static_assert(logging::LOG_FATAL == MOJO_LOG_LEVEL_FATAL,
26 "fatal log level value mismatch");
27
28 int MojoToChromiumLogLevel(MojoLogLevel log_level) {
29 // See the compile asserts above.
30 return static_cast<int>(log_level);
31 }
32
33 MojoLogLevel ChromiumToMojoLogLevel(int chromium_log_level) {
34 // See the compile asserts above.
35 return static_cast<MojoLogLevel>(chromium_log_level);
36 }
37
38 void LogMessage(MojoLogLevel log_level,
39 const char* source_file,
40 uint32_t source_line,
41 const char* message) {
42 int chromium_log_level = MojoToChromiumLogLevel(log_level);
43 int chromium_min_log_level = logging::GetMinLogLevel();
44 // "Fatal" errors aren't suppressable.
45 DCHECK_LE(chromium_min_log_level, logging::LOG_FATAL);
46 if (chromium_log_level < chromium_min_log_level)
47 return;
48
49 // TODO(vtl): Possibly, we should try to pull out the file and line number
50 // from |message|.
51 logging::LogMessage(__FILE__, __LINE__, chromium_log_level).stream()
52 << message;
53 }
54
55 MojoLogLevel GetMinimumLogLevel() {
56 return ChromiumToMojoLogLevel(logging::GetMinLogLevel());
57 }
58
59 void SetMinimumLogLevel(MojoLogLevel log_level) {
60 logging::SetMinLogLevel(MojoToChromiumLogLevel(log_level));
61 }
62
63 const MojoLogger kDefaultLogger = {
64 LogMessage,
65 GetMinimumLogLevel,
66 SetMinimumLogLevel
67 };
68
69 } // namespace
70
71 const MojoLogger* GetDefaultLoggerImpl() {
72 return &kDefaultLogger;
73 }
74
75 } // namespace internal
76 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/environment/default_logger_impl.h ('k') | mojo/environment/default_run_loop_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698