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

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

Issue 330933004: Mojo: Add basic logging facilities to 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
(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/public/cpp/environment/default_logger.h"
6
7 #include <stdio.h>
8 #include <stdlib.h> // For |abort()|.
9
10 namespace mojo {
11 namespace {
12
13 const char* GetLogLevelString(MojoLogLevel log_level) {
14 if (log_level < MOJO_LOG_LEVEL_VERBOSE)
15 return "VERBOSE";
16 switch (log_level) {
17 case MOJO_LOG_LEVEL_VERBOSE:
18 return "VERBOSE";
19 case MOJO_LOG_LEVEL_INFO:
20 return "INFO";
21 case MOJO_LOG_LEVEL_WARNING:
22 return "WARNING";
23 case MOJO_LOG_LEVEL_ERROR:
24 return "ERROR";
25 }
26 // Consider everything higher to be fatal.
27 return "FATAL";
28 }
29
30 void LogMessage(MojoLogLevel log_level, const char* message) {
31 // TODO(vtl): Add timestamp also?
32 fprintf(stderr, "%s:%s\n", GetLogLevelString(log_level), message);
darin (slow to review) 2014/06/14 06:08:23 nit: it might be nice to add a space after the col
33 if (log_level >= MOJO_LOG_LEVEL_FATAL)
34 abort();
35 }
36
37 const MojoLogger kDefaultLogger = {
38 LogMessage
39 };
40
41 } // namespace
42
43 const MojoLogger* GetDefaultLogger() {
44 return &kDefaultLogger;
45 }
46
47 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698