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.
5 #include "mojo/logging/init_logging.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
14 ::logging::LoggingDestination
DetermineLogMode(
15 const base::CommandLine
& command_line
) {
16 // only use OutputDebugString in debug mode
18 bool enable_logging
= false;
19 const char* kInvertLoggingSwitch
= "enable-logging";
21 bool enable_logging
= true;
22 const char* kInvertLoggingSwitch
= "disable-logging";
24 const ::logging::LoggingDestination kDefaultLoggingMode
=
25 ::logging::LOG_TO_SYSTEM_DEBUG_LOG
;
27 if (command_line
.HasSwitch(kInvertLoggingSwitch
))
28 enable_logging
= !enable_logging
;
30 return enable_logging
? kDefaultLoggingMode
: ::logging::LOG_NONE
;
36 ::logging::LoggingSettings settings
;
37 settings
.logging_dest
= DetermineLogMode(
38 *base::CommandLine::ForCurrentProcess());
39 ::logging::InitLogging(settings
);
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
48 } // namespace logging