From 10d69f9da63bdf18b802bd34fc528294ec340f86 Mon Sep 17 00:00:00 2001 From: szmeti Date: Tue, 12 Apr 2016 16:14:02 +0200 Subject: [PATCH] Missing loglevel public API methods added (#8914) --- loglevel/loglevel-tests.ts | 10 ++++++++++ loglevel/loglevel.d.ts | 40 +++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/loglevel/loglevel-tests.ts b/loglevel/loglevel-tests.ts index ab19939569..ca1ebc1664 100644 --- a/loglevel/loglevel-tests.ts +++ b/loglevel/loglevel-tests.ts @@ -16,6 +16,11 @@ log.setLevel("error", false); log.setLevel(LogLevel.WARN); log.setLevel(LogLevel.WARN, false); +log.enableAll(false); +log.enableAll(); +log.disableAll(true); +log.disableAll(); + var logLevel = log.getLevel(); var testLogger = log.getLogger("TestLogger"); @@ -26,3 +31,8 @@ testLogger.warn("logging test"); var logging = log.noConflict(); logging.error("still pretty easy"); + +log.methodFactory = function(methodName: string, level: LogLevel, loggerName :string) { + return function(...messages: any[]) { + }; +}; \ No newline at end of file diff --git a/loglevel/loglevel.d.ts b/loglevel/loglevel.d.ts index 0d8352c652..7ccbe89c33 100644 --- a/loglevel/loglevel.d.ts +++ b/loglevel/loglevel.d.ts @@ -1,6 +1,6 @@ // Type definitions for loglevel 1.4.0 // Project: https://github.com/pimterry/loglevel -// Definitions by: Stefan Profanter , Florian Wagner +// Definitions by: Stefan Profanter , Florian Wagner , Gabor Szmetanko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** @@ -15,8 +15,28 @@ declare const enum LogLevel { SILENT = 5 } +interface LoggingMethod { + + (...message : any[]):void; + +} + +interface MethodFactory { + + (methodName : string, level : LogLevel, loggerName : string):LoggingMethod; + +} + interface Log { + /** + * Plugin API entry point. This will be called for each enabled method each time the level is set + * (including initially), and should return a MethodFactory to be used for the given log method, at the given level, + * for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's + * recommended that this wraps the initially provided value of log.methodFactory + */ + methodFactory:MethodFactory; + /** * Output trace message to console. * This will also include a full stack trace @@ -135,6 +155,24 @@ interface Log { */ getLogger(name : String):Log; + /** + * This enables all log messages, and is equivalent to log.setLevel("trace"). + * + * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling + * back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass + * false as the optional 'persist' second argument, persistence will be skipped. + */ + enableAll(persist? : boolean):void; + + /** + * This disables all log messages, and is equivalent to log.setLevel("silent"). + * + * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling + * back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass + * false as the optional 'persist' second argument, persistence will be skipped. + */ + disableAll(persist? : boolean):void; + } declare var log : Log;