Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2246 (closed defect: invalid)

Opened 10 years ago

Last modified 10 years ago

tg/configuration.py passes a logging.Logger instead of expected stream object

Reported by: amol Owned by:
Priority: normal Milestone: 2.0rc1
Component: TurboGears Version: 2.0b6
Severity: normal Keywords:
Cc:

Description

tg/configuration.py : add_auth_middleware does:

        # Configuring auth logging:
        if 'log_stream' not in self.sa_auth:
            self.sa_auth['log_stream'] = logging.getLogger('auth')

but repoze.who expects to get a stream object with write method in sa_authlog_stream? and so raises an exception when performing stream.write on the logger

repoze/who/middleware.py : PluggableAuthenticationMiddleware? : init does

        if log_stream:
            handler = logging.StreamHandler(log_stream)
            fmt = '%(asctime)s %(message)s'
            formatter = logging.Formatter(fmt)
            handler.setFormatter(formatter)
            self.logger = logging.Logger('repoze.who')
            self.logger.addHandler(handler)
            self.logger.setLevel(log_level)

which creates a new logger from log_stream using it as a StreamHandler? even if it is already a Logger instance.

Change History

comment:1 Changed 10 years ago by Gustavo

  • Status changed from new to closed
  • Resolution set to invalid

Recent versions of repoze.who's PluggableAuthenticationMiddleware support both a stream and a logger itself:

        if isinstance(log_stream, logging.Logger):
            self.logger = log_stream
        elif log_stream:
            handler = logging.StreamHandler(log_stream)
            fmt = '%(asctime)s %(message)s'
            formatter = logging.Formatter(fmt)
            handler.setFormatter(formatter)
            self.logger = logging.Logger('repoze.who')
            self.logger.addHandler(handler)
            self.logger.setLevel(log_level)

You seem to be using an old version of repoze.who. Please upgrade (the latest one, as of this writing, is 1.0.10):

easy_install -U repoze.who

If you still get this error, please use the turbogears-trunk mailing list and don't forget to include a traceback.

Note: See TracTickets for help on using tickets.