TRC_BNEP=2
TRC_PAN=2
+# This is Log configuration for new C++ code using LOG() macros.
+# See libchrome/base/logging.h for description on how to configure your logs.
+# sample configuration:
+#LoggingV=--v=0
+#LoggingVModule=--vmodule=*/btm/*=1,btm_ble_multi*=2,btif_*=1
+
# PTS testing helpers
# Secure connections only mode.
# ========================================================
include $(CLEAR_VARS)
+LOCAL_CPP_EXTENSION := .cc
+
+#
+# Workaround for libchrome and -DNDEBUG usage.
+#
+# Test whether the original TARGET_GLOBAL_CFLAGS contains -DNDEBUG.
+# This is needed as a workaround to make sure that
+# libchrome and local files calling logging::InitLogging()
+# are consistent with the usage of -DNDEBUG .
+# ========================================================
+ifneq (,$(findstring NDEBUG,$(TARGET_GLOBAL_CFLAGS)))
+ btmain_orig_TARGET_NDEBUG := -DBT_LIBCHROME_NDEBUG
+else
+ btmain_orig_TARGET_NDEBUG :=
+endif
+
# platform specific
LOCAL_SRC_FILES := \
bte_main.c \
bte_init.c \
bte_logmsg.c \
+ bte_init_cpp_logging.cc \
bte_conf.c \
stack_config.c
libbt-hci \
libbt-vendor
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
+LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG $(btmain_orig_TARGET_NDEBUG)
LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
--- /dev/null
+/******************************************************************************
+ *
+ * Copyright (C) 2016 Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifdef BT_LIBCHROME_NDEBUG
+#define NDEBUG 1
+#endif
+
+#include <base/command_line.h>
+#include "main_int.h"
+
+void init_cpp_logging(config_t *config) {
+ // Command line and log level might be also configured in service/main.cpp
+ // when running the bluetoothtbd daemon. If it's already configured, skip
+ // configuring.
+ if (base::CommandLine::InitializedForCurrentProcess()) return;
+
+ const char *loggingV =
+ config_get_string(config, CONFIG_DEFAULT_SECTION, "LoggingV", NULL);
+ const char *loggingVModule =
+ config_get_string(config, CONFIG_DEFAULT_SECTION, "LoggingVModule", NULL);
+
+ int argc = 1;
+ const char *argv[] = {"bt_stack", NULL, NULL};
+
+ if (loggingV != NULL) {
+ argv[argc] = loggingV;
+ argc++;
+ }
+
+ if (loggingVModule != NULL) {
+ argv[argc] = loggingVModule;
+ argc++;
+ }
+
+ // Init command line object with logging switches
+ base::CommandLine::Init(argc, argv);
+
+ logging::LoggingSettings log_settings;
+ if (!logging::InitLogging(log_settings)) {
+ LOG(ERROR) << "Failed to set up logging";
+ }
+
+ // Android already logs thread_id, proc_id, timestamp, so disable those.
+ logging::SetLogItems(false, false, false, false);
+}
\ No newline at end of file
#include "port_api.h"
#include "sdp_api.h"
#include "stack_config.h"
+#include "main_int.h"
#if (AVDT_INCLUDED == TRUE)
#include "avdt_api.h"
}
static future_t *init(void) {
+
const stack_config_t *stack_config = stack_config_get_interface();
if (!stack_config->get_trace_config_enabled()) {
LOG_INFO(LOG_TAG, "using compile default trace settings");
return NULL;
}
+ init_cpp_logging(stack_config->get_all());
+
load_levels_from_config(stack_config->get_all());
return NULL;
}
--- /dev/null
+/******************************************************************************
+ *
+ * Copyright (C) 2016 Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef MAIN_INT_H
+#define MAIN_INT_H
+
+#include "osi/include/config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Initiates the logging for C++ */
+void init_cpp_logging(config_t *config);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MAIN_INT_H
\ No newline at end of file