Skip to content

Commit

Permalink
Try to set log formatter
Browse files Browse the repository at this point in the history
Signed-off-by: disaster37 <[email protected]>
  • Loading branch information
disaster37 committed Aug 24, 2021
1 parent 34a803a commit 04798ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 8 additions & 0 deletions kb/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kb
import (
"net/url"
"time"
"os"

kibana "github.com/disaster37/go-kibana-rest/v7"
"github.com/disaster37/go-kibana-rest/v7/kbapi"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/t-tomalak/logrus-easy-formatter"
)

// Provider define kibana provider
Expand Down Expand Up @@ -96,6 +98,12 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
waitBeforeRetry := d.Get("wait_before_retry").(int)
debug := d.Get("debug").(bool)

log.SetFormatter(&easy.Formatter{
LogFormat: "[%lvl%] %msg%",
})
log.SetOutput(os.Stdout)
log.SetLevel(log.InfoLevel)

if debug {
log.SetLevel(log.DebugLevel)
}
Expand Down
8 changes: 0 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@ import (
"github.com/disaster37/terraform-provider-kibana/v7/kb"

"github.com/hashicorp/terraform-plugin-sdk/plugin"
log "github.com/sirupsen/logrus"
"github.com/t-tomalak/logrus-easy-formatter"
)

func main() {
log.SetFormatter(&easy.Formatter{
LogFormat: "[%lvl%] %msg%",
})
log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)

plugin.Serve(&plugin.ServeOpts{
ProviderFunc: kb.Provider,
})
Expand Down

0 comments on commit 04798ec

Please sign in to comment.