Skip to content

Commit

Permalink
Fix: remove warnings on datetime.utcnow
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeyk committed Dec 17, 2024
1 parent 9f95a67 commit c8dc5eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/belogging/filters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
from collections import OrderedDict
from datetime import datetime
from datetime import datetime, timezone
from threading import Lock

from .defaults import LEVEL_MAP
Expand Down Expand Up @@ -61,7 +61,7 @@ def filter(self, record):
msg = record.getMessage()
with self.lock:
if msg in self._cache:
now = datetime.utcnow()
now = datetime.now(timezone.utc)
delta = now - self._cache[msg]["time"]
if delta.seconds >= self._cache_expire:
self._cache[msg]["time"] = now
Expand All @@ -78,6 +78,6 @@ def filter(self, record):
self._cache.pop(key, None)

with self.lock:
self._cache[msg] = {"time": datetime.utcnow(), "hits": 0}
self._cache[msg] = {"time": datetime.now(timezone.utc), "hits": 0}

return True

0 comments on commit c8dc5eb

Please sign in to comment.