• Class decorator that automatically injects a shared logger into a KOS model.

    This decorator eliminates the need for manual logger setup in constructors by:

    • Creating a single shared logger per model type (not per instance)
    • Using the KosLoggerFactory for consistent logger creation
    • Following KOS naming conventions for logger context
    • Providing optimal performance through logger reuse

    Performance Note: Creates one logger per model type, shared across all instances of that type. This is much more efficient than per-instance logger creation.

    Important: Use TypeScript interface merging to get proper type information:

    interface MyModelImpl extends KosLoggerAware {}

    @kosModel("my-model")
    @kosLoggerAware()
    export class MyModelImpl implements IKosDataModel {
    // logger property is now available with full type safety
    async doSomething() {
    this.logger.debug("Doing something...");
    }
    }

    Parameters

    • Optional options: KosLoggerAwareOptions

      Configuration options for the logger injection

    Returns ClassDecorator

    A class decorator

    Example

    // Basic usage with default logger property
    @kosLoggerAware()
    class MyModel { }

    // Custom logger property name
    @kosLoggerAware({ loggerProperty: 'log' })
    class MyModel {
    // this.log is available instead of this.logger
    }

    // Custom logger context for specialized logging
    @kosLoggerAware({ loggerContext: 'analytics' })
    class AnalyticsModel {
    // Logger uses "analytics" context instead of model type
    }

    Since

    2.1.0