add sub logger to each addon

This commit is contained in:
əlemi 2022-04-25 04:43:00 +02:00
parent b73a352484
commit 4e4bb50e4a
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -55,6 +55,8 @@ class ConfigObject:
class Addon: class Addon:
name: str name: str
config: ConfigObject config: ConfigObject
logger: logging.Logger
_client: 'Treepuncher' _client: 'Treepuncher'
@dataclass(frozen=True) @dataclass(frozen=True)
@ -86,6 +88,7 @@ class Addon:
else: # not really necessary since it's a dataclass but whatever else: # not really necessary since it's a dataclass but whatever
opts[field.name] = default opts[field.name] = default
self.config = self.Options(**opts) self.config = self.Options(**opts)
self.logger = self._client.logger.getChild(self.name)
self.register() self.register()
def register(self): def register(self):