• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2016 Android Open Source Project
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 #include <base/command_line.h>
19 #include <base/logging.h>
20 #include "main_int.h"
21 
init_cpp_logging(config_t * config)22 void init_cpp_logging(config_t* config) {
23   // Command line and log level might be also configured in service/main.cpp
24   // when running the bluetoothtbd daemon. If it's already configured, skip
25   // configuring.
26   if (base::CommandLine::InitializedForCurrentProcess()) return;
27 
28   const std::string* loggingV =
29       config_get_string(*config, CONFIG_DEFAULT_SECTION, "LoggingV", NULL);
30   const std::string* loggingVModule = config_get_string(
31       *config, CONFIG_DEFAULT_SECTION, "LoggingVModule", NULL);
32 
33   int argc = 1;
34   const char* argv[] = {"bt_stack", NULL, NULL};
35 
36   if (loggingV != NULL) {
37     argv[argc] = loggingV->c_str();
38     argc++;
39   }
40 
41   if (loggingVModule != NULL) {
42     argv[argc] = loggingVModule->c_str();
43     argc++;
44   }
45 
46   // Init command line object with logging switches
47   base::CommandLine::Init(argc, argv);
48 
49   logging::LoggingSettings log_settings;
50   if (!logging::InitLogging(log_settings)) {
51     LOG(ERROR) << "Failed to set up logging";
52   }
53 
54   // Android already logs thread_id, proc_id, timestamp, so disable those.
55   logging::SetLogItems(false, false, false, false);
56 }
57