Has noone ever had this king of need ??
On May 17, 11:59 pm, "Joseph.Piron" <joseph.pi...@gmail.com> wrote: > Hi all, > > I was wondering what would be the best way to log actions with the > username of the logger user. > I found several leads but none very conclusive. > > For example, define a filter in my model: > > import logging > class ContextFilter(logging.Filter): > def filter(self, record): > record.user = auth.user.username if hasattr(auth.user, > 'username') else "<None>" > return True > > logger = logging.getLogger("web2py.app." + > request.application.lower()) > if len(logger.filters) == 0: > logger.addFilter(ContextFilter()) > > but two issues: auth.user = None in runtime when the context is the > filter method (tried with eclipse debugger) > and moreover, would it work, I would have to define new handlers to > get a new formatter using this new attribute.. not very handy. > > What could be the best option here ? > > Thanks in advance for your advices!