9
9
"errors"
10
10
"fmt"
11
11
"github.com/pquerna/ffjson/ffjson"
12
- "github.com/strongo/log "
12
+ "github.com/strongo/logus "
13
13
"github.com/technoweenie/multipartstreamer"
14
14
"io"
15
15
"net/http"
@@ -75,7 +75,7 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (apiResp APIR
75
75
if resp , err = bot .Client .PostForm (method , params ); err != nil {
76
76
if strings .Contains (err .Error (), "DEADLINE_EXCEEDED" ) {
77
77
hadDeadlineExceeded = true
78
- log .Warningf (bot .c , "#%v fail to send POST due to DEADLINE_EXCEEDED to %v, will retry: %v" , i , method , err )
78
+ logus .Warningf (bot .c , "#%v fail to send POST due to DEADLINE_EXCEEDED to %v, will retry: %v" , i , method , err )
79
79
continue
80
80
}
81
81
}
@@ -84,21 +84,21 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (apiResp APIR
84
84
if resp != nil && resp .Body != nil {
85
85
defer func () {
86
86
if err := resp .Body .Close (); err != nil {
87
- log .Warningf (bot .c , "failed to close response body: %v" , err )
87
+ logus .Warningf (bot .c , "failed to close response body: %v" , err )
88
88
}
89
89
}()
90
90
}
91
91
92
92
if err != nil {
93
- log .Errorf (bot .c , "Failed to send POST to %v: %v" , method , err .Error ())
93
+ logus .Errorf (bot .c , "Failed to send POST to %v: %v" , method , err .Error ())
94
94
return APIResponse {Ok : false }, fmt .Errorf ("%v: %s: %w" , "POST" , method , err )
95
95
}
96
96
97
97
var body []byte
98
98
if resp .ContentLength > 0 {
99
99
var readerErr error
100
100
if body , readerErr = io .ReadAll (resp .Body ); err != nil {
101
- log .Errorf (bot .c , "Failed to read response.body: %v" , readerErr )
101
+ logus .Errorf (bot .c , "Failed to read response.body: %v" , readerErr )
102
102
if err == nil {
103
103
err = readerErr
104
104
}
@@ -124,8 +124,8 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (apiResp APIR
124
124
125
125
logRequestAndResponse := func () {
126
126
if bot .c != nil {
127
- log .Debugf (bot .c , "Request to Telegram API: %v => %v" , endpoint , params )
128
- log .Debugf (bot .c , "Telegram API response: %v" , string (body ))
127
+ logus .Debugf (bot .c , "Request to Telegram API: %v => %v" , endpoint , params )
128
+ logus .Debugf (bot .c , "Telegram API response: %v" , string (body ))
129
129
}
130
130
}
131
131
@@ -248,7 +248,7 @@ func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldna
248
248
}
249
249
250
250
if bot .c != nil {
251
- log .Debugf (bot .c , string (body ))
251
+ logus .Debugf (bot .c , string (body ))
252
252
}
253
253
254
254
var apiResp APIResponse
@@ -336,11 +336,11 @@ func (bot *BotAPI) Send(c Chattable) (Message, error) {
336
336
337
337
// debugLog checks if the bot is currently running in debug mode, and if
338
338
// so will display information about the request and response in the
339
- // debug log .
339
+ // debug logus .
340
340
func (bot * BotAPI ) debugLog (context string , v url.Values , message interface {}) {
341
341
if bot .c != nil {
342
- log .Debugf (bot .c , "%s req : %+v\n " , context , v )
343
- log .Debugf (bot .c , "%s resp: %+v\n " , context , message )
342
+ logus .Debugf (bot .c , "%s req : %+v\n " , context , v )
343
+ logus .Debugf (bot .c , "%s resp: %+v\n " , context , message )
344
344
}
345
345
}
346
346
@@ -522,7 +522,7 @@ func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) {
522
522
}
523
523
524
524
if bot .c != nil {
525
- log .Debugf (bot .c , "setWebhook resp: %+v\n " , apiResp )
525
+ logus .Debugf (bot .c , "setWebhook resp: %+v\n " , apiResp )
526
526
}
527
527
528
528
return apiResp , nil
@@ -537,8 +537,8 @@ func (bot *BotAPI) GetUpdatesChan(config *UpdateConfig) (<-chan Update, error) {
537
537
for {
538
538
updates , err := bot .GetUpdates (config )
539
539
if err != nil {
540
- //log .Println(err)
541
- //log .Println("Failed to get updates, retrying in 3 seconds...")
540
+ //logus .Println(err)
541
+ //logus .Println("Failed to get updates, retrying in 3 seconds...")
542
542
time .Sleep (time .Second * 3 )
543
543
544
544
continue
@@ -565,7 +565,7 @@ func (bot *BotAPI) ListenForWebhook(pattern string) <-chan Update {
565
565
566
566
var update Update
567
567
if err := ffjson .Unmarshal (body , & update ); err != nil {
568
- log .Errorf (context .Background (), fmt .Errorf ("failed to unmarshal update JSON: %w" , err ).Error ())
568
+ logus .Errorf (context .Background (), fmt .Errorf ("failed to unmarshal update JSON: %w" , err ).Error ())
569
569
return
570
570
}
571
571
0 commit comments