UNPKG

2.36 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.dev/license
7 */
8import { Observable, Operator, PartialObserver, Subject, Subscription } from 'rxjs';
9import { JsonObject } from '../json/utils';
10export interface LoggerMetadata extends JsonObject {
11 name: string;
12 path: string[];
13}
14export interface LogEntry extends LoggerMetadata {
15 level: LogLevel;
16 message: string;
17 timestamp: number;
18}
19export interface LoggerApi {
20 createChild(name: string): Logger;
21 log(level: LogLevel, message: string, metadata?: JsonObject): void;
22 debug(message: string, metadata?: JsonObject): void;
23 info(message: string, metadata?: JsonObject): void;
24 warn(message: string, metadata?: JsonObject): void;
25 error(message: string, metadata?: JsonObject): void;
26 fatal(message: string, metadata?: JsonObject): void;
27}
28export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
29export declare class Logger extends Observable<LogEntry> implements LoggerApi {
30 readonly name: string;
31 readonly parent: Logger | null;
32 protected readonly _subject: Subject<LogEntry>;
33 protected _metadata: LoggerMetadata;
34 private _obs;
35 private _subscription;
36 protected get _observable(): Observable<LogEntry>;
37 protected set _observable(v: Observable<LogEntry>);
38 constructor(name: string, parent?: Logger | null);
39 asApi(): LoggerApi;
40 createChild(name: string): Logger;
41 complete(): void;
42 log(level: LogLevel, message: string, metadata?: JsonObject): void;
43 next(entry: LogEntry): void;
44 debug(message: string, metadata?: JsonObject): void;
45 info(message: string, metadata?: JsonObject): void;
46 warn(message: string, metadata?: JsonObject): void;
47 error(message: string, metadata?: JsonObject): void;
48 fatal(message: string, metadata?: JsonObject): void;
49 toString(): string;
50 lift<R>(operator: Operator<LogEntry, R>): Observable<R>;
51 subscribe(): Subscription;
52 subscribe(observer: PartialObserver<LogEntry>): Subscription;
53 subscribe(next?: (value: LogEntry) => void, error?: (error: Error) => void, complete?: () => void): Subscription;
54 forEach(next: (value: LogEntry) => void, promiseCtor?: PromiseConstructorLike): Promise<void>;
55}