@nsalaun/ng-logger
Version:
Angular logger service
98 lines (97 loc) • 4.16 kB
TypeScript
/**
* @license
* Copyright Noémi Salaün All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/noemi-salaun/ng-logger/blob/master/LICENSE
*/
import { InjectionToken } from '@angular/core';
import { Level } from './level.enum';
import * as i0 from "@angular/core";
/**
* Created by Noémi Salaün on 09/17/2016.
*/
/**
* The token to provide the log {@link Level}.
*/
export declare const LOGGER_LEVEL: InjectionToken<Level>;
/**
* A logger service that provide the same functions as {@link console}.
* The logger is binded to the console, so the Web Console shows the correct file and line number of the original call.
*/
export declare class Logger {
/**
* The log level.
*/
private readonly _level;
/**
* Outputs a message to the Web Console.
* @param message A JavaScript string containing zero or more substitution strings.
* @param optionalParams A list of JavaScript objects to output
* OR JavaScript objects with which to replace substitution strings within message.
*/
log: (message?: any, ...optionalParams: any[]) => void;
/**
* Outputs a debugging message to the Web Console.
* @param message A JavaScript string containing zero or more substitution strings.
* @param optionalParams A list of JavaScript objects to output
* OR JavaScript objects with which to replace substitution strings within message.
*/
debug: (message?: any, ...optionalParams: any[]) => void;
/**
* Outputs an informational message to the Web Console.
* @param message A JavaScript string containing zero or more substitution strings.
* @param optionalParams A list of JavaScript objects to output
* OR JavaScript objects with which to replace substitution strings within message.
*/
info: (message?: any, ...optionalParams: any[]) => void;
/**
* Outputs a warning message to the Web Console.
* @param message A JavaScript string containing zero or more substitution strings.
* @param optionalParams A list of JavaScript objects to output
* OR JavaScript objects with which to replace substitution strings within message.
*/
warn: (message?: any, ...optionalParams: any[]) => void;
/**
* Outputs an error message to the Web Console.
* @param message A JavaScript string containing zero or more substitution strings.
* @param optionalParams A list of JavaScript objects to output
* OR JavaScript objects with which to replace substitution strings within message.
*/
error: (message?: any, ...optionalParams: any[]) => void;
/**
* Creates a new inline group in the Web Console log.
* @param groupTitle An optional title for the group.
*/
group: (groupTitle?: string) => void;
/**
* Creates a new inline group in the Web Console log that is initially collapsed.
* @param groupTitle An optional title for the group.
*/
groupCollapsed: (groupTitle?: string) => void;
/**
* Exits the current inline group in the Web Console.
*/
groupEnd: () => void;
/**
* Starts a timer you can use to track how long an operation takes.
* It works only with log {@link Level} equal or higher than DEBUG.
*
* @param timerName The name to give the new timer. This will identify the timer.
*/
time: (timerName?: string) => void;
/**
* Stops a timer that was previously started by calling {@link Logger.time}.
* It works only with log {@link Level} equal or higher than DEBUG.
*
* @param timerName The name of the timer to stop. Once stopped, the elapsed time is automatically displayed in the Web Console.
*/
timeEnd: (timerName?: string) => void;
/**
* Returns the log level.
*/
get level(): Level;
constructor(level: Level);
static ɵfac: i0.ɵɵFactoryDeclaration<Logger, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<Logger>;
}