import { Logger } from './Logger'; /** * Represents a type that has a `logger` property * containing the Logger singleton instance */ // export type Loggable = T & { logger: Logger }; /** * Class decorator that transforms a class to Loggable. * Regrettably works but is not properly picked up by intellisense * at this point in time, meaning compiler errors when attempting * to access the `logger` property on the decorated class. * Maybe someday. * * Example: * ``` * @loggable * class Foo { } * ``` */ // export function loggable(target: T): Loggable // { // Object.defineProperty(target.prototype, 'logger', // { value: Logger.instance }); // return > target; // } /** * Property decorator that will automatically assign * the Logger singleton instance to the decorated * class property * * Example: * ``` * class Foo { * @logger private readonly logger: Logger; * ... * ``` * >**Note:** This is a Typescript feature. If using the logger is desired * in Javascript you should simply retrieve the singleton instance via * `Logger.instance()` * @returns {PropertyDecorator} */ export function logger(target: T, key: string): void { Object.defineProperty(target, key, { value: Logger.instance() }); }