#5872 enhancement new
Add a new interface to twisted.python.log which encourages structured logging
|Reported by:||ashfall||Owned by:|
Description (last modified by glyph)
This interface should make it easy to log everything that is germane to a particular event efficiently. Particularly: where (what module, what class) is it from? It should also make it a little more convenient to actually structure your message and think about it beforehand; in other words it should make it ever so slightly harder to just slap some random text into the log.
Here's a basic sketch of what I mean:
Here are some sketches on how it might be used:
doingSomeStuff = log.Event("doing some stuff to %(a)s and %(b)s", __name__) def stuff(a, b): doingSomeStuff(a=a, b=b) # or events = log.Template.forModule(__name__) doingSomeStuff = events.event("doing some stuff to %(a)s and %(b)s") doingOtherStuff = events.event("doing other stuff to %(c)s") # and/or also class MyFunClass(object): logHadFun = log.EventDescriptor("had some fun with %(c)s and %(d)s") def haveFun(self, c, d): self.logHadFun(c=c, d=d, audience=self.log.coreDeveloper)
Another interesting field is who might want to know about it. Examples of who might want to know:
- administrators running the thing that is doing the logging
- local end users
- developers of the module that is doing the logging (debugging messages)
- developers of code that calls the module doing the logging (like, for example, a deprecation)
- users of a remote system (i.e.; I'm sending email to some server, it's misconfigured)
- authors of the software run on a remote system (i.e.; I'm sending email to some server, it's got a bug where it emits out-of-spec or gibberish protocol messages)
There should be separate tickets filed to make use of this information in various ways as well. For example, we should be able to filter the messages by audience, or by module, or by package (in other words, hierarchically by FQPN). The log could then be configured with assertions like "I'm a developer of txfoo, which uses twisted.bar and twisted.baz", or "I'm a system administrator".
Here is the mailing list thread that discusses this.
Change History (14)
comment:9 in reply to: ↑ 7 Changed 3 years ago by glyph
- Summary changed from Add a new interface to logging which mandates structured logging to Add a new interface to logging which encourages structured logging
comment:11 Changed 3 years ago by glyph
- Summary changed from Add a new interface to logging which encourages structured logging to Add a new interface to twisted.python.log which encourages structured logging