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 #include <syslog.h>
21 
22 #define LOG_TAG "SoftKeymaster"
23 #include <cutils/log.h>
24 
25 namespace keymaster {
26 
log_msg(LogLevel level,const char * fmt,va_list args) const27 int SoftKeymasterLogger::log_msg(LogLevel level, const char* fmt, va_list args) const {
28 
29     int android_log_level = ANDROID_LOG_ERROR;
30     switch (level) {
31     case DEBUG_LVL:
32         android_log_level = ANDROID_LOG_DEBUG;
33         break;
34     case INFO_LVL:
35         android_log_level = ANDROID_LOG_INFO;
36         break;
37     case WARNING_LVL:
38         android_log_level = ANDROID_LOG_WARN;
39         break;
40     case ERROR_LVL:
41         android_log_level = ANDROID_LOG_ERROR;
42         break;
43     case SEVERE_LVL:
44         android_log_level = ANDROID_LOG_ERROR;
45         break;
46     }
47 
48     return LOG_PRI_VA(android_log_level, LOG_TAG, fmt, args);
49 }
50 
51 }  // namespace keymaster
52