API Reference

error-log

API entries in this module: 5

Current error-log implementation

In the default setup, IErrorLog uses the ErrorLog class as a shared singleton service.

add(error) logs the error to the console and also emits it through the observable error stream. clear() clears the console.

The module also includes PrettyPrinter and printValue to format complex values for debugging output.

Example: use IErrorLog service

import {
  InjectionContainer,
  RsXCoreInjectionTokens,
  RsXCoreModule,
  type IErrorLog,
  type IError,
} from '@rs-x/core';

await InjectionContainer.load(RsXCoreModule);

const errorLog = InjectionContainer.get<IErrorLog>(
  RsXCoreInjectionTokens.IErrorLog,
);

const subscription = errorLog.error.subscribe((entry: IError) => {
  console.log('logged error:', entry.message);
});

errorLog.add({
  message: 'Something failed',
  context: 'Expression evaluation',
  fatal: false,

How to extend or modify

Create your own IErrorLog implementation (for example memory/remote logging) and rebind RsXCoreInjectionTokens.IErrorLog to that class in singleton scope.

Override error-log service

import {
  ContainerModule,
  Injectable,
  InjectionContainer,
  RsXCoreInjectionTokens,
  type IError,
  type IErrorLog,
} from '@rs-x/core';
import { Subject } from 'rxjs';

@Injectable()
class MemoryErrorLog implements IErrorLog {
  private readonly stream = new Subject<IError>();
  public readonly error = this.stream.asObservable();
  private readonly history: IError[] = [];

  public add(error: IError): void {
    this.history.push(error);
    this.stream.next(error);
  }

  public clear(): void {