Skip to content

Conversation

@mdumandag
Copy link
Contributor

Contrary to what https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
advises, we were defining our own StreamHandler with custom formatter and
filter. It is strongly advised for libraries to not do that. We are following that
advice now. In short, the changes done are described below.

  • Use module-level loggers with the module name as the logger name. It is described
    as a good convention in the https://docs.python.org/3/howto/logging.html#advanced-logging-tutorial.
  • Do not add a Handler with custom formatter and filter by default.
  • Do not print the latest commit id in the Lifecycle service as it requires reading a file
    during the client startup. Instead, the client version is printed. To make test failure
    reports easier to follow, the latest commit id is printed for the test logs.
  • For tests, a single configuration is added to the root logger in the init file.
    That way, all tests will reuse that.
  • Do not pass logger extras anymore as they don't make sense without a custom formatter or
    filter. We may provide utility implementations for a formatter and a filter and pass
    extras even if they won't be used most of the time. I chose not to pass them, but that
    can be discussed.
  • Remove logging_level and logging_config confiugration options.
  • Update README.

Contrary to what https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
advises, we were defining our own StreamHandler with custom formatter and
filter. It is strongly advised for libraries to not do that. We are following that
advice now. In short, the changes done are described below.

- Use module-level loggers with the module name as the logger name. It is described
as a good convention in the https://docs.python.org/3/howto/logging.html#advanced-logging-tutorial.
- Do not add a Handler with custom formatter and filter by default.
- Do not print the latest commit id in the Lifecycle service as it requires reading a file
during the client startup. Instead, the client version is printed. To make test failure
reports easier to follow, the latest commit id is printed for the test logs.
- For tests, a single configuration is added to the root logger in the init file.
That way, all tests will reuse that.
- Do not pass logger extras anymore as they don't make sense without a custom formatter or
filter. We may provide utility implementations for a formatter and a filter and pass
extras even if they won't be used most of the time. I chose not to pass them, but that
can be discussed.
- Remove `logging_level` and `logging_config` confiugration options.
- Update README.
Copy link

@puzpuzpuz puzpuzpuz left a comment

Choose a reason for hiding this comment

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

Looks like a good improvement 👍

@mdumandag mdumandag merged commit c06434d into hazelcast:master Nov 5, 2020
@mdumandag mdumandag deleted the logging branch November 5, 2020 14:05
@mdumandag mdumandag linked an issue Nov 11, 2020 that may be closed by this pull request
mdumandag added a commit to mdumandag/hazelcast-python-client that referenced this pull request Nov 18, 2020
Documentation about logging_config and logging_level were not
removed in hazelcast#229. This removes them, since they are not usable
anymore.
mdumandag added a commit to mdumandag/hazelcast-python-client that referenced this pull request Nov 19, 2020
Documentation about logging_config and logging_level were not
removed in hazelcast#229. This removes them, since they are not usable
anymore.
mdumandag added a commit that referenced this pull request Nov 19, 2020
Documentation about logging_config and logging_level were not
removed in #229. This removes them, since they are not usable
anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix default log format to match a python style

2 participants