soft_keymaster_logger.cpp 1.4 KB

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