@miracledevs/paradigm-web-angular
Version:
An angular wrapper with base functionality and helper services.
179 lines (178 loc) • 5.07 kB
TypeScript
/*!
* Paradigm Framework - Angular Wrapper
* Copyright (c) 2017 Miracle Devs, Inc
* Licensed under MIT (https://github.com/MiracleDevs/Paradigm.Web.Shared/blob/master/LICENSE)
*/
import { ServiceBase } from './base.service';
/**
* Represents a log provider.
* The interface was specifically made to
* match the one from @see console that is
* the default provider used by @see LoggingService.
*/
export interface ILogProvider {
/**
* Adds a trace log.
* @param message the message to be logged.
*/
trace(message: string): void;
/**
* Adds a debug log.
* @param message the message to be logged.
*/
debug(message: string): void;
/**
* Adds an info log.
* @param message the message to be logged.
*/
info(message: string): void;
/**
* Adds a warn log.
* @param message the message to be logged.
*/
warn(message: string): void;
/**
* Adds an error log.
* @param message the message to be logged.
*/
error(message: string): void;
/**
* Adds a critical error log.
* @param message the message to be logged.
*/
critical?(message: string): void;
}
/**
* Enumerates the types of logging entries.
*/
export declare enum LogType {
/**
* Represents a trace log.
*/
Trace = 0,
/**
* Represents a debug log.
*/
Debug = 1,
/**
* Represents an information log.
*/
Information = 2,
/**
* Represents a warning log.
*/
Warning = 3,
/**
* Represents an error log.
*/
Error = 4,
/**
* Represents a critical error log.
*/
Critical = 5
}
export declare class LoggingService extends ServiceBase {
/**
* Error message.
*/
private static readonly typeNotRecognized;
/**
* An array of message templates.
*/
private messageTemplates;
/**
* The minimum log type that will logged.
* Log types smaller than this value will be ignored.
*/
private minimumLevel;
/**
* A log provider.
* By default @see console will be used.
*/
private logProvider;
/**
* Creates a new instance of @see LoggingService.
*/
constructor();
/**
* Sets a log provider.
* By default @see console is used as provider.
*/
setLogProvider(logProvider: ILogProvider): void;
/**
* Sets the message template for a given log type.
* There are some predefined content placeholders the user can utilize
* to configure the custom messages:
*
* {0}: The time when the log was added.
*
* {1}: The type of the log (Trace, Debug , Information, etc)
*
* {2}: A custom tag value provided by the user.
*
* {3}: The log message.
*/
setMessageTemplate(type: LogType, message: string): void;
/**
* Sets the message template for all the types.
* There are some predefined content placeholders the user can utilize
* to configure the custom messages:
*
* {0}: The time when the log was added.
*
* {1}: The type of the log (Trace, Debug , Information, etc)
*
* {2}: A custom tag value provided by the user.
*
* {3}: The log message.
*/
setMessageTemplateForAll(message: string): void;
/**
* Sets the minimum log level.
* Log types smaller than this value will be ignored.
*/
setMinimumLevel(type: LogType): void;
/**
* Logs the specified message.
* @param message the message to be logged.
* @param type the type of log entry.
* @param tag a tag value used for further analysis.
*/
log(message: string, type?: LogType, tag?: string): void;
/**
* Adds a trace log entry.
* @param message the message to be logged.
* @param tag a tag value for the entry.
*/
trace(message: string, tag?: string): void;
/**
* Adds a debug log entry.
* @param message the message to be logged.
* @param tag a tag value for the entry.
*/
debug(message: string, tag?: string): void;
/**
* Adds an information log entry.
* @param message the message to be logged.
* @param tag a tag value for the entry.
*/
information(message: string, tag?: string): void;
/**
* Adds a warning log entry.
* @param message the message to be logged.
* @param tag a tag value for the entry.
*/
warning(message: string, tag?: string): void;
/**
* Adds an error log entry.
* @param message the message to be logged.
* @param tag a tag value for the entry.
*/
error(message: string, tag?: string): void;
/**
* Adds a critical error log entry.
* @param message the message to be logged.
* @param tag a tag value for the entry.
*/
critical(message: string, tag?: string): void;
}