#9008 defect closed duplicate (duplicate)

Can’t change namespace for the Logger instance

Reported by: RomanMeR Owned by:
Priority: normal Milestone:
Component: logger Keywords: logger
Cc: Branch:
Author: Roman Mescheryakov

Description

I use Twisted 16.6.0 and wrote the following simple program:

import sys
from twisted.logger import (Logger, textFileLogObserver)
 
class MyClass:
   log = Logger(namespace = "ad_hoc", observer = textFileLogObserver(sys.stdout))
   def __init__(self):
       self.log.info("MyClass.__init__ called!")
 
   def __del__(self):
       self.log.info("Bye!")
 
obj = MyClass()

I call it with Python 2.7.13:

python loggertest.py

and get this output:

2017-01-20T12:25:18+0300 [__main__.MyClass#info] MyClass.__init__ called!
2017-01-20T12:25:18+0300 [__main__.MyClass#info] Bye!

Expected: the text between ‘[‘ and ‘#’ is ‘ad_hoc’ Actual: it is auto-generated name "main.MyClass" instead.

Glyph Lefkowitz confirmed this is a bug.

Change History (1)

comment:1 Changed 11 months ago by Wilfredo Sánchez Vega

Resolution: duplicate
Status: newclosed

Duplicate of #8841

Note: See TracTickets for help on using tickets.