Skip to content

refactor plugin base #44

@cademirch

Description

@cademirch

If I were to make one significant change to the logger plugin system, I think it might be better to replace LogHandlerBase with a class that is not itself a log hander but creates one from a factory method. The constructor and properties would stay more or less the same.

  • Currently you cannot inherit from builtin handler classes like StreamHandler or FileHandler due to how LogHandlerBase's constructor works. You could get around this, probably by requiring __post_init__() to call the appropriate handler's __init__() method instead, but it's all a bit messy with the multiple/diamond inheritance.
  • Many usages probably don't even need a custom Handler subclass, and could just use a builtin one with a custom formatter.
  • It would be easier to change behavior according to config. The issue I'm running into is logging to stderr vs a file.

This could be made backwards compatible with the old method by having an implementation of the new class that just wraps the old LogHandlerBase instance.

Originally posted by @jlumpe in #37

TODO:

  • solidfy new base class design
  • decide how to handle backwards compatibility/deprecation of current base class
  • think about log file paths
  • determine changes needed upstream (pair this with feat: add event dataclasses #32 probably)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions