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