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

Allow braces in log messages #39

Merged
merged 3 commits into from
Nov 4, 2021

Conversation

michaeljb
Copy link
Contributor

@michaeljb michaeljb commented Nov 3, 2021

  • add some failing tests for new behavior

  • DRY out other tests with helper function

  • in CumulusLogger.createMessage, call str.format iff args/kwargs are given

    • this allows the user more freedom in what is in their logging and error strings,
      including JSON strings plus additional text about the JSON; with the previous
      behavior, createMessage raises an IndexError or KeyError if the log (or
      error) message has any curly braces in it but no args/kwargs due to the
      str.format call
    • fixes the newly added unit tests

[Fixes #38]

…re given

    * this allows the user more freedom in what is in their logging and error
      strings, including JSON strings plus additional text about the JSON; with
      the previous behavior, `createMessage` raises an `IndexError` or
      `KeyError` if the log (or error) message has any curly braces in it but no
      args/kwargs due to the `str.format` call

    * fix the new unit tests added in 34ede6d
self.assertTrue(logger.logger.getEffectiveLevel() == logging.INFO)
logger.debug("test logging level debug")
logger.info("test logging level info")
logger.warning("test logging level warning")

def test_simple_message_with_braces_no_args(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I committed these new tests in 34ede6d before committing the fix; to see the failing behavior:

git checkout 34ede6d
nosetests tests/test_logger.py

@michaeljb michaeljb changed the title Allow braces in log messages [Fixes #38] Allow braces in log messages Nov 3, 2021
@markdboyd markdboyd changed the base branch from master to merge/nsidc-allow-branches November 4, 2021 16:09
@markdboyd markdboyd merged commit 0e3cd91 into nasa:merge/nsidc-allow-branches Nov 4, 2021
@michaeljb michaeljb deleted the allow-braces branch November 4, 2021 16:34
@michaeljb michaeljb restored the allow-braces branch November 4, 2021 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants