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
19namespace keymaster {
20
21Logger* Logger::instance_ = 0;
22
23/* static */
24int 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 */
31int 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 */
40int 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 */
49int 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 */
57int 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 */
65int 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 */
73int 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