blob: c7076014ab403aa70fb84a79cece99d835ef6098 [file] [log] [blame]
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +09001/*
2 * Copyright 2018-present Open Networking Foundation
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
17package logger
18
19import (
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090020 "log"
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090021 "strings"
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090022)
23
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090024func Error(s string, opts ...interface{}) {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090025 trimmed := strings.TrimRight(s, "\n")
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090026 if len(opts) == 0 {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090027 log.Printf("[ERROR]:%s\n", trimmed)
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090028 } else {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090029 fmt := "[ERROR]:" + trimmed + "\n"
30 log.Printf(fmt, opts...)
31 }
32}
33
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090034func Debug(s string, opts ...interface{}) {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090035 trimmed := strings.TrimRight(s, "\n")
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090036 if len(opts) == 0 {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090037 log.Printf("[DEBUG]:%s\n", trimmed)
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090038 } else {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090039 fmt := "[DEBUG]:" + trimmed + "\n"
40 log.Printf(fmt, opts...)
41 }
42}
43
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090044func Info(s string, opts ...interface{}) {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090045 trimmed := strings.TrimRight(s, "\n")
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090046 if len(opts) == 0 {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090047 log.Printf("[INFO]:%s\n", trimmed)
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090048 } else {
Keita NISHIMOTOc66b8eb2018-10-20 07:19:39 +090049 fmt := "[INFO]:" + trimmed + "\n"
50 log.Printf(fmt, opts...)
51 }
Keita NISHIMOTO9708e042018-10-27 09:24:44 +090052}