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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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 "base/logging.h"
8 #include "base/macros.h"
9
10 namespace mojo {
11 namespace internal {
12 namespace {
13
14 // We rely on log levels being the same numerically:
15 COMPILE_ASSERT(logging::LOG_VERBOSE == MOJO_LOG_LEVEL_VERBOSE,
16 verbose_log_level_value_mismatch);
17 COMPILE_ASSERT(logging::LOG_INFO == MOJO_LOG_LEVEL_INFO,
18 info_log_level_value_mismatch);
19 COMPILE_ASSERT(logging::LOG_WARNING == MOJO_LOG_LEVEL_WARNING,
20 warning_log_level_value_mismatch);
21 COMPILE_ASSERT(logging::LOG_ERROR == MOJO_LOG_LEVEL_ERROR,
22 error_log_level_value_mismatch);
23 COMPILE_ASSERT(logging::LOG_FATAL == MOJO_LOG_LEVEL_FATAL,
24 fatal_log_level_value_mismatch);
25
26 int MojoToChromiumLogLevel(MojoLogLevel log_level) {
27 // See the compile asserts above.
28 return static_cast<int>(log_level);
29 }
30
31 MojoLogLevel ChromiumToMojoLogLevel(int chromium_log_level) {
32 // See the compile asserts above.
33 return static_cast<MojoLogLevel>(chromium_log_level);
34 }
35
36 void LogMessage(MojoLogLevel log_level,
37 const char* source_file,
38 uint32_t source_line,
39 const char* message) {
40 int chromium_log_level = MojoToChromiumLogLevel(log_level);
41 int chromium_min_log_level = logging::GetMinLogLevel();
42 // "Fatal" errors aren't suppressable.
43 DCHECK_LE(chromium_min_log_level, logging::LOG_FATAL);
44 if (chromium_log_level < chromium_min_log_level)
45 return;
46
47 logging::LogMessage(source_file, source_line, chromium_log_level).stream()
48 << message;
49 }
50
51 MojoLogLevel GetMinimumLogLevel() {
52 return ChromiumToMojoLogLevel(logging::GetMinLogLevel());
53 }
54
55 void SetMinimumLogLevel(MojoLogLevel log_level) {
56 logging::SetMinLogLevel(MojoToChromiumLogLevel(log_level));
57 }
58
59 const MojoLogger kDefaultLogger = {
60 LogMessage,
61 GetMinimumLogLevel,
62 SetMinimumLogLevel
63 };
64
65 } // namespace
66
67 const MojoLogger* GetDefaultLoggerImpl() {
68 return &kDefaultLogger;
69 }
70
71 } // namespace internal
72 } // 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