-
Notifications
You must be signed in to change notification settings - Fork 3
/
log.go
46 lines (39 loc) · 854 Bytes
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2023, Intel Corporation.
// SPDX-License-Identifier: BSD-3-Clause
// Package log provides internal used log function like Debug and Info.
// User can change the log level by setting environment variable IXL_LOG_LEVEL.
package log
import (
"log"
"os"
)
var level = 0
const (
lvlSilent = 0
lvlInfo = 1
lvlDebug = 2
)
func init() {
if lvl := os.Getenv("IXL_LOG_LEVEL"); lvl != "" {
switch lvl {
case "SILENT":
level = lvlSilent
case "INFO":
level = lvlInfo
case "DEBUG":
level = lvlDebug
}
}
}
// Debug prints debug level logs
func Debug(format string, args ...interface{}) {
if level >= lvlDebug {
log.Printf("[ixl-go]DEBG "+format, args...)
}
}
// Info prints info level logs
func Info(format string, args ...interface{}) {
if level >= lvlInfo {
log.Printf("[ixl-go]INFO "+format, args...)
}
}