This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
forked from scaleway/terraform-provider-scaleway
-
Notifications
You must be signed in to change notification settings - Fork 3
/
logger.go
47 lines (37 loc) · 1.45 KB
/
logger.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
47
package scaleway
import (
"log"
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
sdkLogger "github.com/scaleway/scaleway-sdk-go/logger"
)
// logger is the implementation of the SDK Logger interface for this terraform plugin.
//
// cf. https://godoc.org/github.com/scaleway/scaleway-sdk-go/logger#Logger
type logger struct {
}
// l is the global logger singleton
var l = logger{}
// Debugf logs to the DEBUG log. Arguments are handled in the manner of fmt.Printf.
func (l logger) Debugf(format string, args ...interface{}) {
log.Printf("[DEBUG] "+format, args...)
}
// Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
func (l logger) Infof(format string, args ...interface{}) {
log.Printf("[INFO] "+format, args...)
}
// Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf.
func (l logger) Warningf(format string, args ...interface{}) {
log.Printf("[WARN] "+format, args...)
}
// Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
func (l logger) Errorf(format string, args ...interface{}) {
log.Printf("[ERROR] "+format, args...)
}
// Printf logs to the DEBUG log. Arguments are handled in the manner of fmt.Printf.
func (l logger) Printf(format string, args ...interface{}) {
l.Debugf(format, args...)
}
// ShouldLog allow the SDK to log only in DEBUG or TRACE levels.
func (l logger) ShouldLog(level sdkLogger.LogLevel) bool {
return logging.IsDebugOrHigher()
}