sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Update log statement with a time that prints #294

Closed jeanconn closed 8 months ago

jeanconn commented 10 months ago

Description

Fixes log statements like:

2023-08-10 08:31:15,261 get_cmds: Getting commands from <chandra_time.Time.DateTime object at 0x7fa1eb0053f0> to <chandra_time.Time.DateTime object at 0x7fa1eb005600> for scenario=Non
e

Interface impacts

Testing

Unit tests

Independent check of unit tests by [REVIEWER NAME]

Functional tests

On master at eb5868

In [1]: import kadi.commands.commands_v2
In [2]: kadi.commands.commands_v2.logger.setLevel('INFO')
In [4]: from Chandra.Time import DateTime
In [5]: cmds = kadi.commands.commands_v2.get_cmds(DateTime("2023:001"), DateTime("2023:005"))
2023-10-20 09:46:46,002 get_cmds: Getting commands from <chandra_time.Time.DateTime object at 0x1179b62f0> to <chandra_time.Time.DateTime object at 0x1179b7550> for scenario=None
2023-10-20 09:46:46,007 get_cmds: Getting commands from archive only because of: scenario=None before_recent_cmds=True HAS_INTERNET=True

On this PR at 507ad83

In [1]: import kadi.commands.commands_v2
In [4]: kadi.commands.commands_v2.logger.setLevel('INFO')
In [9]: from Chandra.Time import DateTime
In [10]: cmds = kadi.commands.commands_v2.get_cmds(DateTime("2023:001"), DateTime("2023:005"))
2023-10-20 09:46:19,730 get_cmds: Getting commands from 2023:001:00:00:00.000 to 2023:005:00:00:00.000 for scenario=None
2023-10-20 09:46:19,732 get_cmds: Getting commands from archive only because of: scenario=None before_recent_cmds=True HAS_INTERNET=True
taldcroft commented 10 months ago

I'd suggest fixing the upstream code.

jeanconn commented 10 months ago

I've been using WIPs to keep track of things I'd like to move forward more than issues. This is totally untested and wasn't for review.

taldcroft commented 10 months ago

I thought DateTime had a decent str repr now, but apparently not.

jeanconn commented 10 months ago

Also, what you consider the "upstream code" for this?

taldcroft commented 10 months ago

Also, what you consider the "upstream code" for this?

Whatever is calling this function. But I just suggested another option.

jeanconn commented 10 months ago

"Whatever is calling this function." Sure -- though from my perspective that would just be kadi_validate_states which seemed a big tree to traverse. So yes, I agree that isolating to just have a generic solution that prints something reasonable at this line in the code makes sense to me.

taldcroft commented 10 months ago

This just needs some functional testing.

taldcroft commented 10 months ago

And flake8, apparently.