The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2012 Broadcom Corporation |
| 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 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * Override the ALOGD(), ALOGE(), and other logging macros from |
| 22 | * /system/core/include/cutils/log.h |
| 23 | * |
| 24 | ******************************************************************************/ |
Ruchi Kandoi | d03c06e | 2017-01-26 15:32:03 -0800 | [diff] [blame] | 25 | #include "_OverrideLog.h" |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 26 | #include <cutils/properties.h> |
Martijn Coenen | 8e290d3 | 2015-04-16 10:08:46 +0200 | [diff] [blame] | 27 | #include <string.h> |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 28 | #include "config.h" |
Evan Chu | a24be4f | 2013-11-13 15:30:16 -0500 | [diff] [blame] | 29 | #include "android_logmsg.h" |
Jizhou Liao | 65ebec5 | 2016-04-05 17:09:24 -0700 | [diff] [blame] | 30 | |
| 31 | #undef LOG_TAG |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 32 | #define LOG_TAG "BrcmNfcJni" |
| 33 | |
| 34 | |
| 35 | /******************************************************************************* |
| 36 | ** |
| 37 | ** Function: initializeGlobalAppLogLevel |
| 38 | ** |
| 39 | ** Description: Initialize and get global logging level from .conf or |
| 40 | ** Android property nfc.app_log_level. The Android property |
| 41 | ** overrides .conf variable. |
| 42 | ** |
| 43 | ** Returns: Global log level: |
| 44 | ** BT_TRACE_LEVEL_NONE 0 * No trace messages to be generated |
| 45 | ** BT_TRACE_LEVEL_ERROR 1 * Error condition trace messages |
| 46 | ** BT_TRACE_LEVEL_WARNING 2 * Warning condition trace messages |
| 47 | ** BT_TRACE_LEVEL_API 3 * API traces |
| 48 | ** BT_TRACE_LEVEL_EVENT 4 * Debug messages for events |
| 49 | ** BT_TRACE_LEVEL_DEBUG 5 * Debug messages (general) |
| 50 | ** |
| 51 | *******************************************************************************/ |
| 52 | unsigned char initializeGlobalAppLogLevel () |
| 53 | { |
| 54 | unsigned long num = 0; |
| 55 | char valueStr [PROPERTY_VALUE_MAX] = {0}; |
| 56 | |
Evan Chu | d8f9332 | 2013-05-10 09:59:20 -0400 | [diff] [blame] | 57 | num = 1; |
| 58 | if (GetNumValue (NAME_APPL_TRACE_LEVEL, &num, sizeof(num))) |
| 59 | appl_trace_level = (unsigned char) num; |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 60 | |
| 61 | int len = property_get ("nfc.app_log_level", valueStr, ""); |
| 62 | if (len > 0) |
| 63 | { |
| 64 | //let Android property override .conf variable |
| 65 | sscanf (valueStr, "%lu", &num); |
| 66 | appl_trace_level = (unsigned char) num; |
| 67 | } |
| 68 | |
| 69 | //0xFF is a special value used by the stack to query the current |
| 70 | //trace level; it does not change any trace level |
| 71 | if (appl_trace_level == 0xFF) |
| 72 | appl_trace_level = BT_TRACE_LEVEL_DEBUG; |
Ruchi Kandoi | 512ee63 | 2017-01-03 13:59:10 -0800 | [diff] [blame] | 73 | ALOGD ("%s: level=%u", __func__, appl_trace_level); |
Evan Chu | a24be4f | 2013-11-13 15:30:16 -0500 | [diff] [blame] | 74 | |
| 75 | if (appl_trace_level < BT_TRACE_LEVEL_DEBUG) |
| 76 | { |
| 77 | //display protocol traces in raw format |
| 78 | ProtoDispAdapterUseRawOutput (TRUE); |
| 79 | } |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 80 | return appl_trace_level; |
| 81 | } |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 82 | |
Ruchi Kandoi | 512ee63 | 2017-01-03 13:59:10 -0800 | [diff] [blame] | 83 | uint32_t initializeProtocolLogLevel () { |
| 84 | uint32_t num = 0; |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 85 | char valueStr [PROPERTY_VALUE_MAX] = {0}; |
| 86 | |
| 87 | if ( GetNumValue ( NAME_PROTOCOL_TRACE_LEVEL, &num, sizeof ( num ) ) ) |
| 88 | ScrProtocolTraceFlag = num; |
| 89 | |
| 90 | int len = property_get ("nfc.enable_protocol_log", valueStr, ""); |
| 91 | if (len > 0) |
| 92 | { |
| 93 | if (strncmp("0", valueStr, 1) == 0) |
| 94 | { |
| 95 | ScrProtocolTraceFlag = 0; |
| 96 | } else { |
| 97 | ScrProtocolTraceFlag = ~0; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return ScrProtocolTraceFlag; |
| 102 | } |
| 103 | |