Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseDate has the less common date format listed first #154

Open
b-jazz opened this issue Oct 24, 2023 · 3 comments
Open

ParseDate has the less common date format listed first #154

b-jazz opened this issue Oct 24, 2023 · 3 comments

Comments

@b-jazz
Copy link

b-jazz commented Oct 24, 2023

I get a lot of log spam in my logs about dates not matching the format string. Upon looking into it the code and the API specs, it looks like the order of formats could be reversed and the amount of log spam could be reduced. It appears that the /api/0.6/notes endpoint generates the "UTC" format, while the rest of the api endpoints generate ISO-8601 (2023-10-24T21:20:27Z) format dates.

The cleaner, slightly more complex solution would to not log an error unless both formats fail to match anything.

    date_formats = ["%Y-%m-%d %H:%M:%S UTC", "%Y-%m-%dT%H:%M:%SZ"]
    for date_format in date_formats:
        try:
            result = datetime.strptime(DateString, date_format)
            return result
        except (ValueError, TypeError):
            logger.debug(f"{DateString} does not match {date_format}")

    return DateString```
@metaodi
Copy link
Owner

metaodi commented Oct 25, 2023

I'll look into it @b-jazz.

But to be fair: those messages are marked "debug" for a reason, maybe you can adjust the logging level on your side. Or is there something important that you would miss (haven't checked the levels in quite some time)?

@b-jazz
Copy link
Author

b-jazz commented Oct 25, 2023

Completely fair. I considered turning down logs for that module, but thought the debug message might not be very useful if both formats exist and it only logs an error on the more common case. I'm not opposed to closing this out without changing anything. Just wanted to bring some light to it.

@b-jazz
Copy link
Author

b-jazz commented Oct 25, 2023

The only logging that osmapi.dom does is that message. So it is safe to just config it out on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants