1 /*
2 * Copyright (C) 2022 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 "chre/platform/log.h"
18 #include "chre/util/macros.h"
19 #include "chre_api/chre/re.h"
20
chreLog(enum chreLogLevel level,const char * formatStr,...)21 DLL_EXPORT void chreLog(enum chreLogLevel level, const char *formatStr, ...) {
22 char logBuf[512];
23 va_list args;
24
25 va_start(args, formatStr);
26 vsnprintf(logBuf, sizeof(logBuf), formatStr, args);
27 va_end(args);
28
29 switch (level) {
30 case CHRE_LOG_ERROR:
31 LOGE("%s", logBuf);
32 break;
33 case CHRE_LOG_WARN:
34 LOGW("%s", logBuf);
35 break;
36 case CHRE_LOG_INFO:
37 LOGI("%s", logBuf);
38 break;
39 case CHRE_LOG_DEBUG:
40 default:
41 LOGD("%s", logBuf);
42 }
43 }
44