blob: d84abc86c681ed7e69b05e8592f522e12cc4d70c [file] [log] [blame]
Shawn Willden538b0652014-12-30 23:23:40 -07001/*
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
19namespace keymaster {
20
21Logger* Logger::instance_ = 0;
22
23int Logger::log(LogLevel level, const char* fmt, ...) const {
24 va_list args;
25 va_start(args, fmt);
26 int result = log_msg(level, fmt, args);
27 va_end(args);
28 return result;
29}
30
31int Logger::debug(const char* fmt, ...) const {
32 va_list args;
33 va_start(args, fmt);
34 int result = log_msg(DEBUG_LVL, fmt, args);
35 va_end(args);
36 return result;
37}
38
39int Logger::info(const char* fmt, ...) const {
40 va_list args;
41 va_start(args, fmt);
42 int result = log_msg(INFO_LVL, fmt, args);
43 va_end(args);
44 return result;
45}
46
47int Logger::warning(const char* fmt, ...) const {
48 va_list args;
49 va_start(args, fmt);
50 int result = log_msg(WARNING_LVL, fmt, args);
51 va_end(args);
52 return result;
53}
54
55int Logger::error(const char* fmt, ...) const {
56 va_list args;
57 va_start(args, fmt);
58 int result = log_msg(ERROR_LVL, fmt, args);
59 va_end(args);
60 return result;
61}
62
63int Logger::severe(const char* fmt, ...) const {
64 va_list args;
65 va_start(args, fmt);
66 int result = log_msg(SEVERE_LVL, fmt, args);
67 va_end(args);
68 return result;
69}
70
71/* static */
72int Logger::Log(LogLevel level, const char* fmt, va_list args) {
73 if (!instance_)
74 return 0;
75 return instance_->log_msg(level, fmt, args);
76}
77
78/* static */
79int Logger::Log(LogLevel level, const char* fmt, ...) {
80 va_list args;
81 va_start(args, fmt);
82 int result = Log(level, fmt, args);
83 va_end(args);
84 return result;
85}
86
87/* static */
88int Logger::Debug(const char* fmt, ...) {
89 va_list args;
90 va_start(args, fmt);
91 int result = Log(DEBUG_LVL, fmt, args);
92 va_end(args);
93 return result;
94}
95
96/* static */
97int Logger::Info(const char* fmt, ...) {
98 va_list args;
99 va_start(args, fmt);
100 int result = Log(INFO_LVL, fmt, args);
101 va_end(args);
102 return result;
103}
104/* static */
105int Logger::Warning(const char* fmt, ...) {
106 va_list args;
107 va_start(args, fmt);
108 int result = Log(WARNING_LVL, fmt, args);
109 va_end(args);
110 return result;
111}
112/* static */
113int Logger::Error(const char* fmt, ...) {
114 va_list args;
115 va_start(args, fmt);
116 int result = Log(ERROR_LVL, fmt, args);
117 va_end(args);
118 return result;
119}
120/* static */
121int Logger::Severe(const char* fmt, ...) {
122 va_list args;
123 va_start(args, fmt);
124 int result = Log(SEVERE_LVL, fmt, args);
125 va_end(args);
126 return result;
127}
128
129
130} // namespace keymaster