Class

LoggedClass

LoggedClass()

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(...)

View Source LoggedClass.ts, line 3

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.

View Source LoggedClass.ts, line 38

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.

View Source LoggedClass.ts, line 56

Logger bound to the subclass context.

Logger