Added log tags to entries
This commit is contained in:
parent
cdd158e17c
commit
b15094fa8d
2 changed files with 11 additions and 5 deletions
|
|
@ -37,18 +37,24 @@ func HandleMessage(c *gin.Context) {
|
|||
}
|
||||
|
||||
func handleSearch(req *MessageRequest) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("[error] Search panicked. Exception info: %s", r)
|
||||
}
|
||||
}()
|
||||
|
||||
cardName, err := getCardNameByCommand(req.Object.Body)
|
||||
if err != nil {
|
||||
Message(req.Object.UserId, "Некорректная команда")
|
||||
log.Printf("Not correct command error message: %s user input: %s", err.Error(), req.Object.Body)
|
||||
log.Printf("[info] Not correct command. Message: %s user input: %s", err.Error(), req.Object.Body)
|
||||
} else if cardName == "" {
|
||||
Message(req.Object.UserId, "Карта не найдена")
|
||||
log.Printf("Could not find card user input: %s", req.Object.Body)
|
||||
log.Printf("[info] Could not find card. User input: %s", req.Object.Body)
|
||||
} else {
|
||||
prices, err := GetPrices(cardName)
|
||||
if err != nil {
|
||||
Message(req.Object.UserId, "Цены временно недоступны, попробуйте позже")
|
||||
log.Printf("Could not find SCG prices error message: %s card name: %s", err.Error(), cardName)
|
||||
log.Printf("[error] Could not find SCG prices. Message: %s card name: %s", err.Error(), cardName)
|
||||
return
|
||||
}
|
||||
elements := min(Cardslimit, len(prices))
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ func Message(userId int64, message string) {
|
|||
paramString := strings.Join(params, "&")
|
||||
resp, err := http.Get(SendMessageUrl + "?" + paramString)
|
||||
if err != nil || resp.StatusCode != http.StatusOK {
|
||||
log.Printf("Could not send message user: %d", userId)
|
||||
log.Printf("[error] Could not send message. User: %d", userId)
|
||||
return
|
||||
}
|
||||
responseBytes, _ := ioutil.ReadAll(resp.Body)
|
||||
var response SendMessageResponse
|
||||
_ = json.Unmarshal(responseBytes, &response)
|
||||
if response.Error.ErrorCode != 0 {
|
||||
log.Printf("Message was not sent message user: %d error message: %s", userId, response.Error.ErrorMsg)
|
||||
log.Printf("[error] Message was not sent. User: %d error message: %s", userId, response.Error.ErrorMsg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue