1/****************************************************************************** 2 * 3 * Copyright (C) 2011-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#include "buildcfg.h" 19#include "bt_types.h" 20#include <cutils/log.h> 21 22 23#ifndef BTE_LOG_BUF_SIZE 24 #define BTE_LOG_BUF_SIZE 1024 25#endif 26#define BTE_LOG_MAX_SIZE (BTE_LOG_BUF_SIZE - 12) 27 28 29extern "C" 30{ 31 void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...); 32} 33 34/******************************************************************************* 35** 36** Function: ScrLog 37** 38** Description: log a message 39** 40** Returns: none 41** 42*******************************************************************************/ 43void ScrLog (UINT32 trace_set_mask, const char *fmt_str, ...) 44{ 45 static char buffer[BTE_LOG_BUF_SIZE]; 46 va_list ap; 47 48 va_start(ap, fmt_str); 49 vsnprintf(buffer, BTE_LOG_MAX_SIZE, fmt_str, ap); 50 va_end(ap); 51 __android_log_write(ANDROID_LOG_INFO, "BrcmNci", buffer); 52} 53 54 55/******************************************************************************* 56** 57** Function: LogMsg 58** 59** Description: log a message 60** 61** Returns: none 62** 63*******************************************************************************/ 64void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...) 65{ 66 static char buffer[BTE_LOG_BUF_SIZE]; 67 va_list ap; 68 UINT32 trace_type = trace_set_mask & 0x07; //lower 3 bits contain trace type 69 int android_log_type = ANDROID_LOG_INFO; 70 71 va_start(ap, fmt_str); 72 vsnprintf(buffer, BTE_LOG_MAX_SIZE, fmt_str, ap); 73 va_end(ap); 74 if (trace_type == TRACE_TYPE_ERROR) 75 android_log_type = ANDROID_LOG_ERROR; 76 __android_log_write(android_log_type, "BrcmNfcNfa", buffer); 77} 78 79