Keita NISHIMOTO | c66b8eb | 2018-10-20 07:19:39 +0900 | [diff] [blame^] | 1 | /* |
| 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 | |
| 17 | package logger |
| 18 | |
| 19 | import ( |
| 20 | "strings" |
| 21 | "log" |
| 22 | ) |
| 23 | |
| 24 | func Error(s string, opts ...interface{}){ |
| 25 | trimmed := strings.TrimRight(s, "\n") |
| 26 | if len(opts) == 0{ |
| 27 | log.Printf("[ERROR]:%s\n", trimmed) |
| 28 | }else{ |
| 29 | fmt := "[ERROR]:" + trimmed + "\n" |
| 30 | log.Printf(fmt, opts...) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | func Debug(s string, opts ...interface{}){ |
| 35 | trimmed := strings.TrimRight(s, "\n") |
| 36 | if len(opts) == 0{ |
| 37 | log.Printf("[DEBUG]:%s\n", trimmed) |
| 38 | }else{ |
| 39 | fmt := "[DEBUG]:" + trimmed + "\n" |
| 40 | log.Printf(fmt, opts...) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | func Info(s string, opts ...interface{}){ |
| 45 | trimmed := strings.TrimRight(s, "\n") |
| 46 | if len(opts) == 0{ |
| 47 | log.Printf("[INFO]:%s\n", trimmed) |
| 48 | }else{ |
| 49 | fmt := "[INFO]:" + trimmed + "\n" |
| 50 | log.Printf(fmt, opts...) |
| 51 | } |
| 52 | } |