1 /*
2 * Copyright 2014 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/logger.h>
18
19 namespace keymaster {
20
21 Logger* Logger::instance_ = nullptr;
22
23 /* static */
Log(LogLevel level,const char * fmt,va_list args)24 int Logger::Log(LogLevel level, const char* fmt, va_list args) {
25 if (!instance_)
26 return 0;
27 return instance_->log_msg(level, fmt, args);
28 }
29
30 /* static */
Log(LogLevel level,const char * fmt,...)31 int Logger::Log(LogLevel level, const char* fmt, ...) {
32 va_list args;
33 va_start(args, fmt);
34 int result = Log(level, fmt, args);
35 va_end(args);
36 return result;
37 }
38
39 /* static */
Debug(const char * fmt,...)40 int Logger::Debug(const char* fmt, ...) {
41 va_list args;
42 va_start(args, fmt);
43 int result = Log(DEBUG_LVL, fmt, args);
44 va_end(args);
45 return result;
46 }
47
48 /* static */
Info(const char * fmt,...)49 int Logger::Info(const char* fmt, ...) {
50 va_list args;
51 va_start(args, fmt);
52 int result = Log(INFO_LVL, fmt, args);
53 va_end(args);
54 return result;
55 }
56 /* static */
Warning(const char * fmt,...)57 int Logger::Warning(const char* fmt, ...) {
58 va_list args;
59 va_start(args, fmt);
60 int result = Log(WARNING_LVL, fmt, args);
61 va_end(args);
62 return result;
63 }
64 /* static */
Error(const char * fmt,...)65 int Logger::Error(const char* fmt, ...) {
66 va_list args;
67 va_start(args, fmt);
68 int result = Log(ERROR_LVL, fmt, args);
69 va_end(args);
70 return result;
71 }
72 /* static */
Severe(const char * fmt,...)73 int Logger::Severe(const char* fmt, ...) {
74 va_list args;
75 va_start(args, fmt);
76 int result = Log(SEVERE_LVL, fmt, args);
77 va_end(args);
78 return result;
79 }
80
81
82 } // namespace keymaster
83