Closed jessicamillar closed 2 years ago
I'm getting UTC when I run your branch locally.
I just pulled this branch and ran:
python test/show_protocol.py
and I get:
## STARTING############################################################################################
2022-08-11T15:35:01.169897+00:00 OUT a.m -> [a.m/p] GsPwr
2022-08-11T15:35:01.170213+00:00 OUT a.m -> [a.m/gt.sh.telemetry.from.multipurpose.sensor.100] GtShTelemetryFromMultipurposeSensor
2022-08-11T15:35:01.170451+00:00 IN a.s <- [a.m/p] GsPwr
2022-08-11T15:35:01.171117+00:00 OUT a.s * -> [dwjess.isone.ct.newhaven.orange1.ta.scada/p] GsPwr
2022-08-11T15:35:01.171337+00:00 IN a.s <- [a.m/gt.sh.telemetry.from.multipurpose.sensor.100] GtShTelemetryFromMultipurposeSensor
2022-08-11T15:35:01.172360+00:00 IN dwjess.isone.ct.newhaven.orange1 * <- [dwjess.isone.ct.newhaven.orange1.ta.scada/p] GsPwr
UTC is definitely the way to go. I didn't do it there only because I figured we were going to redo logging and would then have to make a consistent decision.
The MessageSummary
class is here acting as a convenient namespace of functions and constants.
I'd like all of our log reports to use UTC time.
In general I like using pendulum over datetime; it does a better job as far as I am concerned about being clear regarding timezones. In particular it does not default to naive time but always includes a timezone in its datetime objects.
I tried to update MessageSummary to do this, replacing datetime.datetime.now() with pendulum.now("UTC"). But strangely, the message logs using MessageSummary are still coming up in local time.
e.g. 2022-08-11T10:48:46.552462 IN w.isone.ct.newhaven.orange1 [ETC]
when shortly after that pendulum.now("UTC").isoformat() returns '2022-08-11T14:49:03.556545+00:00'
I am also unfamiliar with creating classes without inits etc as you did with MessageSummary. I figure this is worth a chat.