66 "errors"
77 "fmt"
88 "io"
9+ "log/slog"
910 "net/url"
1011 "os"
1112 "os/signal"
@@ -18,7 +19,6 @@ import (
1819
1920 yaml "github.com/ghodss/yaml"
2021 resty "github.com/go-resty/resty/v2"
21- log "github.com/sirupsen/logrus"
2222 "github.com/spf13/viper"
2323
2424 "strings"
@@ -43,11 +43,7 @@ type Response struct {
4343// URLHelper returns a URL built from the arguments
4444func URLHelper (section , command string ) (string , error ) {
4545 base := viper .GetString ("endpoint" )
46- log .WithFields (log.Fields {
47- "base" : base ,
48- "section" : section ,
49- "command" : command ,
50- }).Debug ("[GenerateURI]" )
46+ slog .Debug ("[GenerateURI]" , "base" , base , "section" , section , "command" , command )
5147
5248 scheme := ""
5349 if ! strings .Contains (base , "://" ) {
@@ -69,11 +65,7 @@ func URLHelper(section, command string) (string, error) {
6965 myurl .Path = path .Clean (myurl .Path )
7066
7167 res , _ := url .PathUnescape (myurl .String ())
72- log .WithFields (log.Fields {
73- "uri" : uri ,
74- "url" : myurl ,
75- "url(string)" : res ,
76- }).Debug ("[GenerateURI] Result" )
68+ slog .Debug ("[GenerateURI] Result" , "uri" , uri , "url" , myurl , "url(string)" , res )
7769 return res , nil
7870}
7971
@@ -108,15 +100,7 @@ func GetRequestTimeout(timeout time.Duration) *resty.Request {
108100 // Registering Response Middleware
109101 client .OnAfterResponse (func (c * resty.Client , resp * resty.Response ) error {
110102 // explore response object
111- log .WithFields (log.Fields {
112- "statuscode" : resp .StatusCode (),
113- "status" : resp .Status (),
114- "time" : resp .Time (),
115- "received-at" : resp .ReceivedAt (),
116- "headers" : resp .Header (),
117- "request" : resp .Request .RawRequest ,
118- "body" : resp ,
119- }).Debug ("Response" )
103+ slog .Debug ("Response" , "statuscode" , resp .StatusCode (), "status" , resp .Status (), "time" , resp .Time (), "received-at" , resp .ReceivedAt (), "headers" , resp .Header (), "request" , resp .Request .RawRequest , "body" , resp )
120104
121105 return nil // if its success otherwise return error
122106 })
0 commit comments