Skip to content

Commit

Permalink
feature: add support for log messages formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
HorlogeSkynet authored and Samuel FORESTIER committed Dec 10, 2023
1 parent d01d881 commit 3ff150f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ New Features

- notifications: Implement 'List-Unsubscribe' header (`#906`_, ix5)
- css: Grey styling for comment code, code blocks (`#907`_, ix5)
- add support for log messages formatting, #976

[general]
log-format =

.. _#906: https://github.com/posativ/isso/pull/906
.. _#907: https://github.com/posativ/isso/pull/907
.. _#976: https://github.com/posativ/isso/pull/976

Breaking Changes
^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions contrib/isso-dev.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ max-age = 15m
notify = stdout
reply-notifications = false
log-file =
log-format =
latest-enabled = true

[admin]
Expand Down
7 changes: 7 additions & 0 deletions docs/docs/reference/server-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Here are the **default values** for this section:
max-age = 15m
notify = stdout
log-file =
log-format =
gravatar = false
gravatar-url = https://www.gravatar.com/avatar/{}?d=identicon&s=55
latest-enabled = false
Expand Down Expand Up @@ -118,6 +119,12 @@ log-file

Default: (empty)

log-format
Format string for console messages logged to file (see Python
`logging.Formatter`).

Default: (empty)

gravatar
When set to ``true`` this will add the property "gravatar_image"
containing the link to a gravatar image to every comment. If a comment
Expand Down
3 changes: 3 additions & 0 deletions isso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def main():
if conf.get("general", "log-file"):
handler = logging.FileHandler(conf.get("general", "log-file"))

if conf.get("general", "log-format"):
handler.setFormatter(logging.Formatter(conf.get("general", "log-format")))

logger.addHandler(handler)
logging.getLogger("werkzeug").addHandler(handler)

Expand Down
4 changes: 4 additions & 0 deletions isso/isso.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ reply-notifications=false
# Log console messages to file instead of standard output.
log-file =

# Format string for console messages logged to file (see Python
# `logging.Formatter`).
log-format =

# adds property "gravatar_image" to json response when true
# will automatically build md5 hash by email and use "gravatar_url" to build
# the url to the gravatar image
Expand Down

0 comments on commit 3ff150f

Please sign in to comment.