xref: /aosp_15_r20/system/keymaster/contexts/soft_keymaster_logger.cpp (revision 789431f29546679ab5188a97751fb38e3018d44d)
1 /*
2  * Copyright 2015 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 <keymaster/soft_keymaster_logger.h>
18 
19 #include <stdarg.h>
20 
21 #ifndef _WIN32
22 #include <syslog.h>
23 #endif
24 
25 #define LOG_TAG "SoftKeymaster"
26 #include <log/log.h>
27 
28 namespace keymaster {
29 
log_msg(LogLevel level,const char * fmt,va_list args) const30 int SoftKeymasterLogger::log_msg(LogLevel level, const char* fmt, va_list args) const {
31 
32     int android_log_level = ANDROID_LOG_ERROR;
33     switch (level) {
34     case DEBUG_LVL:
35         android_log_level = ANDROID_LOG_DEBUG;
36         break;
37     case INFO_LVL:
38         android_log_level = ANDROID_LOG_INFO;
39         break;
40     case WARNING_LVL:
41         android_log_level = ANDROID_LOG_WARN;
42         break;
43     case ERROR_LVL:
44         android_log_level = ANDROID_LOG_ERROR;
45         break;
46     case SEVERE_LVL:
47         android_log_level = ANDROID_LOG_ERROR;
48         break;
49     }
50 
51     return LOG_PRI_VA(android_log_level, LOG_TAG, fmt, args);
52 }
53 
54 }  // namespace keymaster
55