Projet

Général

Profil

Bug #5281

Log ip and user name when possible

Ajouté par Benjamin Dauvergne il y a plus de 9 ans. Mis à jour il y a environ 9 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
-
Version cible:
Début:
14 août 2014
Echéance:
% réalisé:

100%

Temps estimé:
Patch proposed:
Non
Planning:

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

Révision a7e2b297 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 9 ans

middleware: add middleware to keep request in thread local storage (refs #5281)

Révision 2b0ad4a4 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 9 ans

utils: add import_class method (refs #5281)

Révision 3327846d (diff)
Ajouté par Benjamin Dauvergne il y a plus de 9 ans

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

Révision 8fdd2657 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 9 ans

settings: use new wrapped logging handler in logging configuration (fixes #5281)

Révision dbbd1ac2 (diff)
Ajouté par Benjamin Dauvergne il y a plus de 9 ans

Add middleware to keep request in thread local storage (refs #5281, refs #5399)

Historique

#2

Mis à jour par Benjamin Dauvergne il y a plus de 9 ans

  • Patch proposed changé de Non à Oui
#3

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(...)".

#4

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.

#5

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.

#6

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
#7

Mis à jour par Benjamin Dauvergne il y a environ 9 ans

  • Version cible mis à 2.1.12
#8

Mis à jour par Benjamin Dauvergne il y a environ 9 ans

  • Statut changé de Résolu (à déployer) à Fermé

Formats disponibles : Atom PDF