103 Commits

Author SHA1 Message Date
Benoit Chesneau
db9de0175d
Merge branch 'master' into 1775-support-log-config-json 2023-05-07 16:16:56 +02:00
samypr100
2ea4699fe7
Fixing errors reported by pycodestyle 2023-01-22 21:20:11 -05:00
mvdbeek
f186fa3a27
Make loggers function atomic
Fixes https://github.com/benoitc/gunicorn/issues/2784:
```
Traceback (most recent call last):
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/uvicorn/workers.py", line 66, in init_process
    super(UvicornWorker, self).init_process()
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
    self.log.close_on_exec()
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/glogging.py", line 381, in close_on_exec
    for log in loggers():
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/glogging.py", line 94, in loggers
    return [logging.getLogger(name) for name in existing]
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/glogging.py", line 94, in <listcomp>
    return [logging.getLogger(name) for name in existing]
RuntimeError: dictionary changed size during iteration
```
2022-04-22 15:33:17 +02:00
Kian-Meng Ang
cf3619f831 Fix typos 2022-01-14 23:34:02 +08:00
Randall Leeds
839d5dc66c Merge pull request #1996 from javabrett/1690-rewritings 2020-04-20 15:37:41 -07:00
Anmar85
d307045984
Add milliseconds option to request_time in access_log (#2218)
Add milliseconds option to request_time in access_log
2020-01-30 15:29:25 +01:00
Takuya Noguchi
ed901637ff Enable pycodestyle 2019-11-28 19:30:38 +09:00
Martin Bašti
7e640f804c Logging: Handle auth type case insensitively
According RFC-7617 (inherited from RFC-2978) schema and parameter names are handled
case insensitively:
```
Note that both scheme and parameter names are matched case-
insensitively.
```

Signed-off-by: Martin Bašti <mbasti@redhat.com>
2019-07-17 18:56:18 +03:00
Brett Randall
b014fa78ee Various code improvements contributed by dilyanpalauzov.
These were originally based on 19.9.0 code and were rebased
with conflicts resolved.

Fixed #1690.

Co-Authored-By: dilyanpalauzov <git-dpa@aegee.org>
Signed-off-by: Brett Randall <javabrett@gmail.com>
2019-07-17 07:32:11 +10:00
Marat
a8963ef1a5 Remove redundant super() arguments 2019-03-16 15:00:07 -07:00
fangfei
6da84c614d Fix root logging
root and logger are same level. https://docs.python.org/2/library/logging.config.html#dictionary-schema-details
2019-01-21 22:51:55 -08:00
Cuong Tran
d20a26a347 updated styling 2018-11-20 00:08:28 +00:00
Cuong Tran
e98f6a039c added capability to take JSON as log's config 2018-11-18 22:14:54 +00:00
Hugo
e974f30517 Drop support for Python 2
Co-Authored-By: Dustin Ingram <di@users.noreply.github.com>
Co-Authored-By: Berker Peksag <berker.peksag@gmail.com>
2018-08-01 15:31:17 +03:00
Fotis Gimian
5ee2ede35c Ensured that default logging streams are prefixed with ext:// so they work correctly 2018-05-24 14:58:27 +10:00
Yun Xu
0af5641117 fixing zero bytes case in atoms access log 2018-05-18 13:15:03 -07:00
Rudolph Froger
d48b600239 Fix AttributeError when --log-syslog is passed (#1773)
Config option `disable_access_log_redirection` does not exist.
This was introduced in 7dc9003dff149e29c0af4d409060d34f9a7775fa.

Fixes #1768
2018-05-06 18:04:40 +03:00
ysymi
e8c65c1414 Optimize the reopen_files by using FileHandler's method: close & _open 2018-04-03 23:11:27 +08:00
Jacob Eiting
f12ef22281 Handle UnicodeDecodeError in _get_user() (#1684)
Fixes #1683
2018-01-18 04:29:25 +03:00
Nicolas Le Manchet
ad44552a03 Fix access logs not emitted when using logconfig_dict
Fixes #1652
2017-12-01 22:42:23 +03:00
Randall Leeds
783c9bee3e Warn on Python < 2.7 for dictConfig 2017-10-29 21:44:10 -07:00
Mat Moore
9d7c857521 The logconfig_dict setting is not available on 2.6 2017-10-29 21:28:53 -07:00
Mat Moore
e6de1a07b4 Issue 1087: support dictConfig logging configuration 2017-10-29 21:28:53 -07:00
Benoit Chesneau
60efb1041e Merge pull request #1528 from hramezani/redirect_accesslog_issue_1403
Redirect accesslog issue 1403
2017-08-22 21:17:59 +02:00
Hasan Ramezani
7dc9003dff Add disable-redirect-access-to-syslog config 2017-08-22 22:43:30 +04:30
zz
5b0ae52c8a Merge remote-tracking branch 'origin/master' into syslog_socktype 2017-07-17 07:48:44 +02:00
Berker Peksag
610596c9d9 Pass log.info() formatted values correctly
It should be

    log.info("%s", "spam")

not

    log.info("%s" % "spam")
2017-07-12 18:07:16 +03:00
zz
af92742143 parse_syslog_address: unix domain socket type default None, since SOCK_STREAM may not be appropriate 2017-06-19 13:03:11 +02:00
benoitc
4bb2925aa4 fix compatibility with python 2.6 2016-07-27 10:22:09 +02:00
benoitc
df84d3d8fe make sure access logs are printed to stdout
logging.StreamHandler deault to sys.stderr, so make sure access log are printed to stdout when choosing "-" by forcing the stream.

Note: access logs were printed to stdout by default when using the config file.

fix #1184
2016-07-27 09:29:56 +02:00
Vivian Ho
b034c81654 merge 2016-06-02 10:52:43 -07:00
benoitc
49ebee1386 redtirect stdout/stderr to logfile
Add the new setting `--caapture-output` to capture output from stdout/stderr to the current log file.

fix #1271
2016-05-21 10:50:32 +02:00
benoitc
65db610afe print error logs on stderr and access logs on stdout
fix #1184
2016-05-02 15:26:15 +02:00
Krzysztof Urbaniak
353508cd8a fix access logging in gaiohttp worker 2016-02-03 00:55:58 +01:00
Benoit Chesneau
6439c3ba7a don't check if a file is writable using os.stat
Some systems edisable like SELINUX disable some flags so ignore the possible
error while chowning a log file. The error will be raised later anyway.

fix #1171
2015-12-29 15:01:23 +01:00
Benoit Chesneau
c805bd2960 check auth before trying to own a file
fix #1157
2015-12-28 13:00:44 +01:00
Randall Leeds
2f8e7503fe Always send access log to syslog if syslog is on 2015-12-27 13:30:37 -08:00
benoitc
45f008187b also ignore binascii error when decoding the user in access log 2015-11-21 11:27:27 +01:00
benoitc
38261b5235 check if the auth type is Basic before getting the user name
fix #1148
2015-11-21 11:27:27 +01:00
Benoit Chesneau
d922df3902 make sure the users can access to the logs
make sure that a user is able to access to the logs after dropping a
privilege.

fix #1116
2015-10-31 09:17:43 +01:00
y.umezaki
7dd8a53c8c Add accesslog params
Fix KeyError

Update access logger tests

Update settings.rst docs
2015-10-22 02:28:35 +09:00
Berker Peksag
dddfcb2826 Fix test_logger in Python 3.2. 2015-07-08 12:38:14 +03:00
Berker Peksag
117ef10176 Add Python 3 support to _get_user(). 2015-07-08 12:15:38 +03:00
Viacheslav Biriukov
5f3dc8ed2b getting username from basic auth header for access logs 2015-07-07 23:32:13 +03:00
Thomas Orozco
410bcfa6e1 Fix statsd logging to work on Python 3
Bytes must be passed to socket.send.

Update tests to ensure an actual socket is used, so that errors like
this can be caught in unit tests in the future.
2015-04-30 14:07:03 +02:00
Berker Peksag
b8cdfaaccd Make Logger.loglevel a class attribute.
This way it will be easier to change log level of a custom
Logger class:

    class MyLogger(gunicorn.glogging.Logger):

        loglevel = logging.WARNING
2015-02-06 08:48:11 +02:00
benoitc
8b6d86ef2b fix debug mode in gaiohttp worker
The debug setting has been removed and now only the debug level can be used to know if
we are in debug mode or not. This change update the gaiohttp worker to handle
that. While I'm here, expose the loglevel from the Logger class.

fix #977
2015-02-04 14:31:00 +01:00
Benoit Chesneau
859a4b4bb4 Merge pull request #945 from berkerpeksag/flake8-cleanup
Use more Pythonic style in gunicorn/.
2014-11-24 23:06:34 +01:00
Matt Long
71f7d353f0 Use sent instead of response_length in access log
Previously, resp.response_length is used for the b atom of the access
log formatter. If the application does not set a content-length header,
response_length is left as `None`, resulting in b being set to the
fallback "-". resp.sent is a more reliable way to determine the number
of bytes in the response body.
2014-11-24 23:03:47 +02:00
Berker Peksag
56e7d15fb8 Use more Pythonic style in gunicorn/. 2014-11-24 18:43:21 +02:00