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

Side by Side Diff: mojo/public/cpp/environment/lib/default_logger.cc

Issue 339403003: Mojo: Make GetDefault{AsyncWaiter,Logger} static methods of Environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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/public/cpp/environment/default_logger.h" 5 #include "mojo/public/cpp/environment/lib/default_logger.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> // For |abort()|. 8 #include <stdlib.h> // For |abort()|.
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "mojo/public/c/environment/logger.h"
13
12 namespace mojo { 14 namespace mojo {
15
13 namespace { 16 namespace {
14 17
15 MojoLogLevel g_minimum_log_level = MOJO_LOG_LEVEL_INFO; 18 MojoLogLevel g_minimum_log_level = MOJO_LOG_LEVEL_INFO;
16 19
17 const char* GetLogLevelString(MojoLogLevel log_level) { 20 const char* GetLogLevelString(MojoLogLevel log_level) {
18 if (log_level < MOJO_LOG_LEVEL_VERBOSE) 21 if (log_level < MOJO_LOG_LEVEL_VERBOSE)
19 return "VERBOSE"; 22 return "VERBOSE";
20 switch (log_level) { 23 switch (log_level) {
21 case MOJO_LOG_LEVEL_VERBOSE: 24 case MOJO_LOG_LEVEL_VERBOSE:
22 return "VERBOSE"; 25 return "VERBOSE";
(...skipping 15 matching lines...) Expand all
38 // TODO(vtl): Add timestamp also? 41 // TODO(vtl): Add timestamp also?
39 fprintf(stderr, "%s:%s\n", GetLogLevelString(log_level), message); 42 fprintf(stderr, "%s:%s\n", GetLogLevelString(log_level), message);
40 if (log_level >= MOJO_LOG_LEVEL_FATAL) 43 if (log_level >= MOJO_LOG_LEVEL_FATAL)
41 abort(); 44 abort();
42 } 45 }
43 46
44 MojoLogLevel GetMinimumLogLevel() { 47 MojoLogLevel GetMinimumLogLevel() {
45 return g_minimum_log_level; 48 return g_minimum_log_level;
46 } 49 }
47 50
48 const MojoLogger kDefaultLogger = { 51 void SetMinimumLogLevel(MojoLogLevel minimum_log_level) {
49 LogMessage, 52 g_minimum_log_level = std::min(minimum_log_level, MOJO_LOG_LEVEL_FATAL);
50 GetMinimumLogLevel 53 }
51 };
52 54
53 } // namespace 55 } // namespace
54 56
55 namespace internal { 57 namespace internal {
56 58
57 // Declared in mojo/public/cpp/environment/lib/default_logger_internal.h: 59 const MojoLogger kDefaultLogger = {
58 void SetMinimumLogLevel(MojoLogLevel minimum_log_level) { 60 LogMessage,
59 g_minimum_log_level = std::min(minimum_log_level, MOJO_LOG_LEVEL_FATAL); 61 GetMinimumLogLevel,
60 } 62 SetMinimumLogLevel
63 };
61 64
62 } // namespace internal 65 } // namespace internal
63 66
64 // Declared in mojo/public/cpp/environment/default_logger.h:
65 const MojoLogger* GetDefaultLogger() {
66 return &kDefaultLogger;
67 }
68
69 } // namespace mojo 67 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/environment/lib/default_logger.h ('k') | mojo/public/cpp/environment/lib/default_logger_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698