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

Side by Side Diff: mojo/environment/default_logger.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.h ('k') | mojo/environment/default_logger_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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #include "mojo/environment/default_logger_impl.h" 5 #include "mojo/environment/default_logger.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "mojo/public/c/environment/logger.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 namespace internal { 12 namespace internal {
12 namespace { 13 namespace {
13 14
14 // We rely on log levels being the same numerically: 15 // We rely on log levels being the same numerically:
15 COMPILE_ASSERT(logging::LOG_VERBOSE == MOJO_LOG_LEVEL_VERBOSE, 16 COMPILE_ASSERT(logging::LOG_VERBOSE == MOJO_LOG_LEVEL_VERBOSE,
16 verbose_log_level_value_mismatch); 17 verbose_log_level_value_mismatch);
17 COMPILE_ASSERT(logging::LOG_INFO == MOJO_LOG_LEVEL_INFO, 18 COMPILE_ASSERT(logging::LOG_INFO == MOJO_LOG_LEVEL_INFO,
18 info_log_level_value_mismatch); 19 info_log_level_value_mismatch);
(...skipping 18 matching lines...) Expand all
37 const char* source_file, 38 const char* source_file,
38 uint32_t source_line, 39 uint32_t source_line,
39 const char* message) { 40 const char* message) {
40 int chromium_log_level = MojoToChromiumLogLevel(log_level); 41 int chromium_log_level = MojoToChromiumLogLevel(log_level);
41 int chromium_min_log_level = logging::GetMinLogLevel(); 42 int chromium_min_log_level = logging::GetMinLogLevel();
42 // "Fatal" errors aren't suppressable. 43 // "Fatal" errors aren't suppressable.
43 DCHECK_LE(chromium_min_log_level, logging::LOG_FATAL); 44 DCHECK_LE(chromium_min_log_level, logging::LOG_FATAL);
44 if (chromium_log_level < chromium_min_log_level) 45 if (chromium_log_level < chromium_min_log_level)
45 return; 46 return;
46 47
47 logging::LogMessage(source_file, source_line, chromium_log_level).stream() 48 if (source_file) {
48 << message; 49 logging::LogMessage(source_file, static_cast<int>(source_line),
50 chromium_log_level).stream()
51 << message;
52 } else {
53 logging::LogMessage("(no file)", 0, chromium_log_level).stream() << message;
54 }
49 } 55 }
50 56
51 MojoLogLevel GetMinimumLogLevel() { 57 MojoLogLevel GetMinimumLogLevel() {
52 return ChromiumToMojoLogLevel(logging::GetMinLogLevel()); 58 return ChromiumToMojoLogLevel(logging::GetMinLogLevel());
53 } 59 }
54 60
55 void SetMinimumLogLevel(MojoLogLevel log_level) { 61 void SetMinimumLogLevel(MojoLogLevel log_level) {
56 logging::SetMinLogLevel(MojoToChromiumLogLevel(log_level)); 62 logging::SetMinLogLevel(MojoToChromiumLogLevel(log_level));
57 } 63 }
58 64
59 const MojoLogger kDefaultLogger = {
60 LogMessage,
61 GetMinimumLogLevel,
62 SetMinimumLogLevel
63 };
64
65 } // namespace 65 } // namespace
66 66
67 const MojoLogger* GetDefaultLoggerImpl() { 67 const MojoLogger kDefaultLogger = {LogMessage,
68 return &kDefaultLogger; 68 GetMinimumLogLevel,
69 } 69 SetMinimumLogLevel};
70 70
71 } // namespace internal 71 } // namespace internal
72 } // namespace mojo 72 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/environment/default_logger.h ('k') | mojo/environment/default_logger_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698