Home | History | Annotate | Download | only in adaptation
      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  ******************************************************************************/
     25 #include "OverrideLog.h"
     26 #include <cutils/properties.h>
     27 #include "config.h"
     28 #define LOG_TAG "NfcNciHal"
     29 
     30 
     31 unsigned char appl_trace_level = BT_TRACE_LEVEL_DEBUG;
     32 
     33 
     34 /*******************************************************************************
     35 **
     36 ** Function:        InitializeGlobalAppLogLevel
     37 **
     38 ** Description:     Initialize and get global logging level from
     39 **                  Android property nfc.app_log_level.
     40 **
     41 ** Returns:         Global log level:
     42 **                  BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
     43 **                  BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
     44 **                  BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
     45 **                  BT_TRACE_LEVEL_API     3        * API traces
     46 **                  BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
     47 **                  BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
     48 **
     49 *******************************************************************************/
     50 unsigned char InitializeGlobalAppLogLevel ()
     51 {
     52     unsigned long num = 0;
     53     char valueStr [PROPERTY_VALUE_MAX] = {0};
     54 
     55     num = 1;
     56     if (GetNumValue (NAME_APPL_TRACE_LEVEL, &num, sizeof(num)))
     57         appl_trace_level = (unsigned char) num;
     58 
     59     int len = property_get ("nfc.app_log_level", valueStr, "");
     60     if (len > 0)
     61     {
     62         //let Android property override default value
     63         sscanf (valueStr, "%lu", &num);
     64         appl_trace_level = (unsigned char) num;
     65     }
     66 
     67     //0xFF is a special value used by the stack to query the current
     68     //trace level; it does not change any trace level
     69     if (appl_trace_level == 0xFF)
     70         appl_trace_level = BT_TRACE_LEVEL_DEBUG;
     71     ALOGD ("%s: level=%u", __FUNCTION__, appl_trace_level);
     72     return appl_trace_level;
     73 }
     74