ionic-logging-service
Version:
Logging functionalities for apps built with Ionic framework
96 lines (95 loc) • 2.98 kB
TypeScript
import * as log4javascript from "log4javascript";
import { LocalStorageAppenderConfiguration } from "./local-storage-appender.configuration";
import { LogMessage } from "./log-message.model";
/**
* An appender which stores the log messages in the browser's local storage.
*
* The messages are saved JSON-serialized.
* You have to configure which key is used for storing the messages.
*
* A typical configuration could be:
*
* ```json
* {
* "localStorageKey": "myLogs",
* "maxMessages": 500,
* "threshold": "INFO"
* }
* ```
*/
export declare class LocalStorageAppender extends log4javascript.Appender {
private static maxMessagesDefault;
private static thresholdDefault;
private maxMessages;
private localStorageKey;
private logMessages;
/**
* Creates a new instance of the appender.
*
* @param configuration configuration for the appender.
*/
constructor(configuration: LocalStorageAppenderConfiguration);
/**
* Load log messages from local storage which are stored there under the given key.
*
* @param localStorageKey local storage key
* @return stored messages
*/
static loadLogMessages(localStorageKey: string): LogMessage[];
/**
* Remove log messages from local storage which are stored there under the given key.
*
* @param localStorageKey local storage key
*/
static removeLogMessages(localStorageKey: string): void;
/**
* Configures the logging depending on the given configuration.
*
* Only the defined properties get overwritten.
* The localStorageKey cannot be modified.
*
* @param configuration configuration data.
*/
configure(configuration: LocalStorageAppenderConfiguration): void;
/**
* Appender-specific method to append a log message.
*
* @param loggingEvent event to be appended.
*/
append(loggingEvent: log4javascript.LoggingEvent): void;
/**
* Gets the appender's name.
* Mainly for unit testing purposes.
*
* @return appender's name
*/
toString(): string;
/**
* Get the key which is used to store the messages in the local storage.
*/
getLocalStorageKey(): string;
/**
* Get the maximum number of messages which will be stored in local storage.
*/
getMaxMessages(): number;
/**
* Set the maximum number of messages which will be stored in local storage.
*
* If the appender stores currently more messages than the new value allows, the oldest messages get removed.
*
* @param value new maximum number
*/
setMaxMessages(value: number): void;
/**
* Gets all messages stored in local storage.
* Mainly for unit testing purposes.
*
* @return stored messages
*/
getLogMessages(): LogMessage[];
/**
* Removes all messages from local storage.
* Mainly for unit testing purposes.
*/
clearLog(): void;
}