fix_: log utc timestamp (#5672)

* fix_: log zone-agnostic time

* chore_: use time.Truncate
This commit is contained in:
Igor Sirotin 2024-08-07 18:54:42 +01:00 committed by GitHub
parent 58a9557c58
commit 01288227d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 12 deletions

View File

@ -202,7 +202,7 @@ func main() {
select {
case <-ticker.C:
count++
timestamp := time.Now().Format(time.RFC3339)
timestamp := time.Now().UTC().Format(time.RFC3339)
logger.Info("Publishing", "id", id, "count", count, "time", timestamp)
inputMessage := common.NewMessage()

View File

@ -1593,8 +1593,8 @@ func (m *Messenger) watchChatsAndCommunitiesToUnmute() {
case <-time.After(1 * time.Minute):
response := &MessengerResponse{}
m.allChats.Range(func(chatID string, c *Chat) bool {
chatMuteTill, _ := time.Parse(time.RFC3339, c.MuteTill.Format(time.RFC3339))
currTime, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
chatMuteTill := c.MuteTill.Truncate(time.Second)
currTime := time.Now().Truncate(time.Second)
if currTime.After(chatMuteTill) && !chatMuteTill.Equal(time.Time{}) && c.Muted {
err := m.persistence.UnmuteChat(c.ID)

View File

@ -856,14 +856,8 @@ func (m *Messenger) CheckCommunitiesToUnmute() (*MessengerResponse, error) {
return nil, fmt.Errorf("couldn't get all communities: %v", err)
}
for _, community := range communities {
communityMuteTill, err := time.Parse(time.RFC3339, community.MuteTill().Format(time.RFC3339))
if err != nil {
return nil, err
}
currTime, err := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
if err != nil {
return nil, err
}
communityMuteTill := community.MuteTill().Truncate(time.Second)
currTime := time.Now().Truncate(time.Second)
if currTime.After(communityMuteTill) && !communityMuteTill.Equal(time.Time{}) && community.Muted() {
err := m.communitiesManager.SetMuted(community.ID(), false)

View File

@ -201,7 +201,12 @@ func (rl *RPCRequestLimiter) Allow(tag string) (bool, error) {
// Check if a number of requests is over the limit within the interval
if time.Since(data.CreatedAt) < data.Period || data.Period.Milliseconds() == LimitInfinitely {
if data.NumReqs >= data.MaxReqs {
log.Info("Number of requests over limit", "tag", tag, "numReqs", data.NumReqs, "maxReqs", data.MaxReqs, "period", data.Period, "createdAt", data.CreatedAt)
log.Info("Number of requests over limit",
"tag", tag,
"numReqs", data.NumReqs,
"maxReqs", data.MaxReqs,
"period", data.Period,
"createdAt", data.CreatedAt.UTC())
return false, ErrRequestsOverLimit
}