diff --git a/src/lib/utils/functions.ts b/src/lib/utils/functions.ts index 4730d65..4c5b234 100644 --- a/src/lib/utils/functions.ts +++ b/src/lib/utils/functions.ts @@ -1,6 +1,4 @@ -import { tap } from 'rxjs/operators'; import { ITrackable } from '../listing/models/trackable'; -import { MonoTypeOperatorFunction } from 'rxjs'; import moment from 'moment'; import { FormGroup } from '@angular/forms'; @@ -20,8 +18,8 @@ export function humanize(value: string, lowercase = true): string { return words.map(capitalize).join(' '); } -export function log(message = ''): MonoTypeOperatorFunction { - return tap(res => console.log(`%c[${moment().format('HH:mm:ss.SSS')}] ${message}`, 'color: yellow;', res)); +export function _log(value: unknown, message = '') { + console.log(`%c[${moment().format('HH:mm:ss.SSS')}] ${message}`, 'color: yellow;', value); } export function toNumber(str: string): number { diff --git a/src/lib/utils/operators.ts b/src/lib/utils/operators.ts index 44c36a6..6cae298 100644 --- a/src/lib/utils/operators.ts +++ b/src/lib/utils/operators.ts @@ -1,5 +1,6 @@ -import { distinctUntilChanged, map, shareReplay } from 'rxjs/operators'; +import { distinctUntilChanged, map, shareReplay, tap } from 'rxjs/operators'; import { MonoTypeOperatorFunction, Observable, OperatorFunction, pipe, UnaryFunction } from 'rxjs'; +import { _log } from './functions'; export function get(predicate: (value: T, index: number) => boolean): OperatorFunction { return map(entities => entities.find(predicate)); @@ -37,3 +38,7 @@ export function boolFactory(obs: Observable, project: (value: T) ); return [result, inverse]; } + +export function log(message = ''): MonoTypeOperatorFunction { + return tap(res => _log(res, message)); +} diff --git a/src/lib/utils/pipes/log.pipe.ts b/src/lib/utils/pipes/log.pipe.ts index e9dd9b9..bf54600 100644 --- a/src/lib/utils/pipes/log.pipe.ts +++ b/src/lib/utils/pipes/log.pipe.ts @@ -1,11 +1,12 @@ import { Pipe, PipeTransform } from '@angular/core'; +import { _log } from '@iqser/common-ui'; @Pipe({ name: 'log', }) export class LogPipe implements PipeTransform { transform(value: T, message = ''): T { - console.log(message, value); + _log(value, message); return value; } }