[debug] Override all per-namespace log settings (#34234)

* extend the Debug interface with log(...args) to enable overriding all per-namespace log settings

* extend author list of debug

* extend debug tests

* nits: replace console.error with console.log
This commit is contained in:
Kristian Brünn
2019-03-28 01:27:38 +01:00
committed by Ron Buckton
parent e87f5a9181
commit 158e2d3343
2 changed files with 7 additions and 1 deletions

View File

@@ -29,3 +29,7 @@ extendedLog("Testing this is also an IDebugger.");
const extendedWithCustomDelimiter: debug1.Debugger = log.extend('with-delim', '.');
extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
debug2.log = console.log.bind(console);
const anotherLogger = debug2("DefinitelyTyped:error");
anotherLogger("This should be printed to stdout");

View File

@@ -5,9 +5,10 @@
// John McLaughlin <https://github.com/zamb3zi>
// Brasten Sager <https://github.com/brasten>
// Nicolas Penin <https://github.com/npenin>
// Kristian Brünn <https://github.com/kristianmitk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var debug: debug.Debug & {debug: debug.Debug, default: debug.Debug};
declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug };
export = debug;
export as namespace debug;
@@ -19,6 +20,7 @@ declare namespace debug {
disable: () => string;
enable: (namespaces: string) => void;
enabled: (namespaces: string) => boolean;
log: (...args: any[]) => any;
names: RegExp[];
skips: RegExp[];