1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <cinttypes>
18
19 #include "chre_api/chre/re.h"
20 #include "chre/platform/log.h"
21 #include "chre/util/macros.h"
22
chreLog(enum chreLogLevel level,const char * formatStr,...)23 DLL_EXPORT void chreLog(enum chreLogLevel level, const char *formatStr, ...) {
24 char logBuf[512];
25 va_list args;
26
27 va_start(args, formatStr);
28 vsnprintf(logBuf, sizeof(logBuf), formatStr, args);
29 va_end(args);
30
31 switch (level) {
32 case CHRE_LOG_ERROR:
33 LOGE("%s", logBuf);
34 break;
35 case CHRE_LOG_WARN:
36 LOGW("%s", logBuf);
37 break;
38 case CHRE_LOG_INFO:
39 LOGI("%s", logBuf);
40 break;
41 case CHRE_LOG_DEBUG:
42 default:
43 LOGD("%s", logBuf);
44 }
45 }
46