Constructor
# new LoggedClass()
Supplies inheriting classes with a lazily created, context-aware Logger via the protected log getter, promoting consistent structured logging without manual wiring.
Base class that provides a ready-to-use logger instance.
sequenceDiagram
participant Client
participant Instance as Subclass Instance
participant Getter as LoggedClass.log
participant Logging as Logging
participant Logger as Logger
Client->>Instance: call someMethod()
Instance->>Getter: access this.log
Getter->>Logging: Logging.for(this)
Logging-->>Getter: return Logger
Getter-->>Instance: return Logger
Instance->>Logger: info/debug/error(...)
Example
class UserService extends LoggedClass {
create(user: User) {
this.log.info(`Creating user ${user.id}`);
}
}
const svc = new UserService();
svc.create({ id: "42" });
Members
# log
Calls Logging.for with the subclass instance to obtain a logger whose context matches the subclass name.
Lazily provides a context-aware logger for the current instance.
Methods
# protected log() → {Logger}
Calls Logging.for with the subclass instance to obtain a logger whose context matches the subclass name.
Lazily provides a context-aware logger for the current instance.
Logger bound to the subclass context.