logger

The logger operator is a utility function for RxJS observables that simplifies logging emitted values using different console functions. This operator is useful for debugging and monitoring the behavior of your observables during development.

Examples

Example 1: Basic Logging

Log emitted values using console.log:

import {logger} from 'ngx-lift';
import {of} from 'rxjs';

of([1, 2, 3]).pipe(logger()).subscribe();
// check your console for result

Example 2: Table Logging

Log emitted values using console.table for better visualization:

import {logger} from 'ngx-lift';
import {of} from 'rxjs';

of([1, 1, 2, 2, 3, 4, 4, 5]).pipe(logger('table')).subscribe();
// check your console for table result

Example 3: Other Console Methods

Use other console methods like warn, error, or info:

import {logger} from 'ngx-lift';
import {of} from 'rxjs';

of([1, 2, 3]).pipe(logger('warn')).subscribe();
of([1, 2, 3]).pipe(logger('error')).subscribe();
of([1, 2, 3]).pipe(logger('info')).subscribe();

API Reference

logger

RxJS operator that logs emitted values using different console functions.

Signature

logger(
  method?: 'log' | 'table' | 'warn' | 'error' | 'info' | 'debug'
): MonoTypeOperatorFunction<T>

Parameters

  • method?: 'log' | 'table' | 'warn' | 'error' | 'info' | 'debug'

    (Optional) The console method to use for logging. Defaults to 'log'.

    Available methods: log, table, warn, error, info, debug.

Returns

An observable that passes through all values while logging them to the console.