Extending this mixin method will give classes a logger
property
containing a reference to the Logger
singleton instance.
Accepts a parent class as a parameter when extending another class
class Foo extends Loggable() {}
class Bar extends Loggable(Baz) {}
Note that this is a mixin function returning a class, not an actual class itself. The method call parentheses are necessary.
Warning: While this is fully functional at runtime, due to a TypeScript compiler bug, this will currently throw a compiler error unless you also import
ILoggable
. However, this will error if using thenoUnusedLocals
compiler option, but in my experience does not trigger TSLint's unused import rule. This was labeled asdone
for the TypeScript 2.5 milestone but was removed with no word so I am unsure of the state of this bug going forward. I'm leaving the code in in hopes the bug will be fixed because I really like this method of attaching the Logger. It was my oringial intention when I first wrote the Logger itself but had to settle for alternatives
Properties:
Name | Type | Description |
---|---|---|
logger |
|
The Logger instance attached to the Loggable class |
- Source: