Skip to content

Commit 7b90166

Browse files
committed
fix timezone warning
1 parent 08ff594 commit 7b90166

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

paddock/settings.py

+24-10
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,8 @@
33
"""
44

55
import logging
6-
76
import os
87
import sys
9-
# https://github.com/Delgan/loguru/issues/1012
10-
# from loguru import logger
11-
12-
# logging_format = (
13-
# "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
14-
# "<level>{level: <8}</level> | "
15-
# "<cyan>{file.path}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"
16-
# )
178

189
# logger.remove()
1910
# logger.add(sys.stderr, format=logging_format)
@@ -25,6 +16,20 @@
2516
from sentry_sdk.integrations.logging import LoggingIntegration
2617
from sentry_sdk.integrations.threading import ThreadingIntegration
2718

19+
# https://github.com/Delgan/loguru/issues/1012
20+
# from loguru import logger
21+
22+
# logging_format = (
23+
# "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
24+
# "<level>{level: <8}</level> | "
25+
# "<cyan>{file.path}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"
26+
# )
27+
28+
29+
# Convert warnings to exceptions for easier debugging
30+
# import warnings
31+
# warnings.filterwarnings("error", category=RuntimeWarning)
32+
2833
env = environ.Env(
2934
# set casting, default value
3035
DEBUG=(bool, False),
@@ -251,13 +256,17 @@
251256
"format": "{asctime} {levelname} {message}",
252257
"style": "{",
253258
},
259+
"verbose": {
260+
"format": "{levelname} {message} {pathname}:{lineno}",
261+
"style": "{",
262+
},
254263
},
255264
"handlers": {
256265
"console": {
257266
# logging handler that outputs log messages to terminal
258267
"class": "logging.StreamHandler",
259268
"level": "DEBUG", # message level to be written to console
260-
"formatter": "timestamp",
269+
"formatter": "verbose",
261270
},
262271
},
263272
"loggers": {
@@ -274,6 +283,11 @@
274283
# django also has database level logging
275284
"level": env("LOGGING_DB_LEVEL")
276285
},
286+
"py.warnings": {
287+
"handlers": ["console"],
288+
"level": "WARNING",
289+
"propagate": True,
290+
},
277291
},
278292
}
279293

telemetry/racing_stats.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from datetime import datetime, timedelta
1+
from datetime import timedelta
22

3+
import django.utils.timezone
34
from django.db import connection
45
from django.db.models import CharField, Count, Max, Q, Value
56
from loguru import logger # noqa F401
@@ -62,7 +63,7 @@ def driver_combos(self, driver=None, range=30, type="circuit", **kwargs):
6263
filter["session__driver__name"] = driver
6364

6465
# Calculate the start date based on the range
65-
start_date = datetime.now() - timedelta(days=range)
66+
start_date = django.utils.timezone.now() - timedelta(days=range)
6667

6768
laps = Lap.objects.filter(**filter)
6869
# Filter laps based on the end time within the range

0 commit comments

Comments
 (0)