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

Side by Side Diff: mojo/logging/init_logging.cc

Issue 1304893008: Adds a common way to initialize logging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/logging/init_logging.h ('k') | no next file » | 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 2015 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/logging/init_logging.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9
10 namespace mojo {
11 namespace logging {
12 namespace {
13
14 ::logging::LoggingDestination DetermineLogMode(
15 const base::CommandLine& command_line) {
16 // only use OutputDebugString in debug mode
17 #if defined(NDEBUG)
18 bool enable_logging = false;
19 const char* kInvertLoggingSwitch = "enable-logging";
20 #else
21 bool enable_logging = true;
22 const char* kInvertLoggingSwitch = "disable-logging";
23 #endif
24 const ::logging::LoggingDestination kDefaultLoggingMode =
25 ::logging::LOG_TO_SYSTEM_DEBUG_LOG;
26
27 if (command_line.HasSwitch(kInvertLoggingSwitch))
28 enable_logging = !enable_logging;
29
30 return enable_logging ? kDefaultLoggingMode : ::logging::LOG_NONE;
31 }
32
33 } // namespace
34
35 void InitLogging() {
36 ::logging::LoggingSettings settings;
37 settings.logging_dest = DetermineLogMode(
38 *base::CommandLine::ForCurrentProcess());
39 ::logging::InitLogging(settings);
40
41 // we want process and thread IDs because we have a lot of things running
42 ::logging::SetLogItems(true, // enable_process_id
43 true, // enable_thread_id
44 true, // enable_timestamp
45 false); // enable_tickcount
46 }
47
48 } // namespace logging
49 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/logging/init_logging.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698