Bug #5281
Log ip and user name when possible
100%
Description
Log should contain ip and username of users by storing the request in a thread local variable. It should be compatible with all existing log handlers.
Fichiers
Révisions associées
utils: add import_class method (refs #5281)
logging_handler: add new logging handler that ip and user info to any handler (refs #5281)
It uses the StoreRequestMiddleware to retrieve ip and user information
settings: use new wrapped logging handler in logging configuration (fixes #5281)
Historique
Mis à jour par Benjamin Dauvergne il y a plus de 9 ans
- Fichier 0001-middleware-add-middleware-to-keep-request-in-thread-.patch 0001-middleware-add-middleware-to-keep-request-in-thread-.patch ajouté
- Fichier 0002-utils-add-import_class-method-refs-5281.patch 0002-utils-add-import_class-method-refs-5281.patch ajouté
- Fichier 0003-logging_handler-add-new-logging-handler-that-ip-and-.patch 0003-logging_handler-add-new-logging-handler-that-ip-and-.patch ajouté
- Fichier 0004-settings-use-new-wrapped-logging-handler-in-logging-.patch 0004-settings-use-new-wrapped-logging-handler-in-logging-.patch ajouté
Mis à jour par Frédéric Péters il y a plus de 9 ans
It would certainly be easier to understand if there were some comments, especially as things are being done in a file for the sole purpose of something happening elsewhere.
class StoreRequestMiddleware(object): """Keep a global reference of the current request, so it can be accessed in faraway place, like the logging subsystem"""
# logging_handler.py class WrappedHandler(object): """Generic class wrapping a logging handler.""" class RequestWrappedHandler(WrappedHandler): """"Wrap a logging handler to add request related variables to the log record."""
Aussi ce n'est pas clair pour moi comment le fill_record est appelé; de ma lecture du code de logging/handlers.py, il y aurait à s'insérer dans un "def emit(...)".
Mis à jour par Benjamin Dauvergne il y a plus de 9 ans
Sorry, those commit were on a sleeping branch and I thought it was finished since it rebased fine but it's really not, the wrapper does not work at all.
Mis à jour par Frédéric Péters il y a plus de 9 ans
- Patch proposed changé de Oui à Non
Fine, I'll remove the "patch proposed" checkbox for now.
Mis à jour par Benjamin Dauvergne il y a plus de 9 ans
- Statut changé de Nouveau à Résolu (à déployer)
- % réalisé changé de 0 à 100
Appliqué par commit 8fdd26574df3a04a5c43243d3f47d94e97d63b93.
Mis à jour par Benjamin Dauvergne il y a environ 9 ans
- Statut changé de Résolu (à déployer) à Fermé
middleware: add middleware to keep request in thread local storage (refs #5281)