Create loggable

This commit is contained in:
Espy | Neko | 404 2018-05-22 22:16:03 +01:00 committed by GitHub
parent f46753ed30
commit f898302d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

21
src/shared_libs/loggable Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
"""
Neko404NotFound 2018, MIT
A mixin class that injects a suitably named logger into class scope
at runtime.
Chosen to make this a slotted class, which means (as far as I can remember)
that it is not suitable to be made into an abc.ABC class. Slots will
enable derived slotted classes to be a bit more efficient at runtime and
boast faster lookups.
"""
import logging
class Loggable:
__slots__ = ('logger',)
def __init_subclass__(cls, **_):
cls.logger = logging.getLogger(cls.__qualname__)