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

added capability to take JSON as log's config #1917

Merged
merged 3 commits into from May 7, 2023

Conversation

kingkuong
Copy link
Contributor

@kingkuong kingkuong commented Nov 13, 2018

Added feature discussed #1775

What changed is that I added the option to take in a JSON file for log's config using the log-config-json param.

Copy link
Collaborator

@tilgovi tilgovi left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you. Would you mind squashing the commits? @berkerpeksag @benoitc how does this look to you?

@kingkuong
Copy link
Contributor Author

Thanks to take a look, I did squash the commits.


Format: https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig

.. versionadded:: 19.9
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think "19.9" should be "20.0" now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there a plan to upgrade to 20.0? The current is 19.9 and this could be going to either 19.10 or 20.0.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The master branch doesn't support Python 2 anymore and since we can't drop Python 2 support in the next 19.x release, we can safely say that the master branch is now 20.0. If you want to update gunicorn.__version__, feel free to submit a separate PR :)

validator = validate_string
default = None
desc = """\
The log config JSON reads config from a JSON file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps using something shorter like "The log config to read from a JSON file." would be better?

@@ -1368,15 +1368,31 @@ class LogConfigDict(Setting):
desc = """\
The log config dictionary to use, using the standard Python
logging module's dictionary configuration format. This option
takes precedence over the :ref:`logconfig` option, which uses the
older file configuration format.
takes precedence over the :ref:`logconfig` and :ref:`logConfigJson` options, which uses the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit: Please wrap lines at 80 chars.

@@ -627,11 +627,11 @@ class WorkerClass(Setting):
A string referring to one of the following bundled classes:

* ``sync``
* ``eventlet`` - Requires eventlet >= 0.9.7 (or install it via
* ``eventlet`` - Requires eventlet >= 0.9.7 (or install it via
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know that your editor did this automatically, but it would be nice not to include cosmetic fixes into this PR. Feel free to submit them as a separate PR.

config_json = json.load(open(cfg.logconfig_json))
config.update(config_json)
dictConfig(config)
except(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit: Add a space after except.

gunicorn/glogging.py Show resolved Hide resolved
@ahsan-ul-haq
Copy link

@tilgovi @berkerpeksag Any thoughts on when this can get merged and released?

Copy link
Collaborator

@berkerpeksag berkerpeksag left a comment

Choose a reason for hiding this comment

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

This looks pretty good, I just left two minor comments.

gunicorn/config.py Show resolved Hide resolved
@@ -1173,11 +1184,11 @@ libraries may be installed using setuptools' ``extra_require`` feature.
A string referring to one of the following bundled classes:

* ``sync``
* ``eventlet`` - Requires eventlet >= 0.9.7 (or install it via
* ``eventlet`` - Requires eventlet >= 0.9.7 (or install it via
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably forgot to rerun make -C docs html :)

@BrettMoan
Copy link

@cuongtranx I today ran into an issue where i was basically trying to use --log-config-dict with a literal file path, which what this PR would enable via --log-config-json. (but obviously since it hasn't ever been merged I could not, infact, do that)

do you have any interest in continuing this PR?

@benoitc benoitc merged commit 400d847 into benoitc:master May 7, 2023
16 of 18 checks passed
@kingkuong
Copy link
Contributor Author

oh wow thanks for merging! This was a looong time ago and I didn't rmb putting this PR at all 😬

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

Successfully merging this pull request may close these issues.

None yet

6 participants