2019-01-29 06:05:37 +00:00
|
|
|
import * as debug1 from "debug";
|
2019-01-29 10:10:47 +00:00
|
|
|
/*tslint:disable-next-line:no-duplicate-imports*/
|
2019-01-29 06:05:37 +00:00
|
|
|
import debug2 from 'debug';
|
2014-10-25 00:32:13 +00:00
|
|
|
|
2019-01-29 10:10:47 +00:00
|
|
|
const log2: debug1.Debugger = debug2("DefinitelyTyped:log");
|
2019-01-29 06:05:37 +00:00
|
|
|
log2("Just text");
|
|
|
|
|
log2("Formatted test (%d arg)", 1);
|
|
|
|
|
log2("Formatted %s (%d args)", "test", 2);
|
|
|
|
|
|
|
|
|
|
debug1.disable();
|
|
|
|
|
debug1.enable("DefinitelyTyped:*");
|
|
|
|
|
|
|
|
|
|
const log: debug1.Debugger = debug1("DefinitelyTyped:log");
|
2014-10-25 00:32:13 +00:00
|
|
|
|
|
|
|
|
log("Just text");
|
|
|
|
|
log("Formatted test (%d arg)", 1);
|
|
|
|
|
log("Formatted %s (%d args)", "test", 2);
|
|
|
|
|
|
2019-01-29 06:05:37 +00:00
|
|
|
log("Enabled?: %s", debug1.enabled("DefinitelyTyped:log"));
|
|
|
|
|
log("Name Enabled: %s", debug1.names.some(name => name.test("DefinitelyTyped:log")));
|
2014-10-25 00:32:13 +00:00
|
|
|
log("Namespace: %s", log.namespace);
|
|
|
|
|
|
2019-01-29 06:05:37 +00:00
|
|
|
const error: debug1.Debugger = debug1("DefinitelyTyped:error");
|
2014-10-25 00:32:13 +00:00
|
|
|
error.log = console.error.bind(console);
|
|
|
|
|
error("This should be printed to stderr");
|
2018-10-04 17:31:25 +00:00
|
|
|
|
2019-01-29 06:05:37 +00:00
|
|
|
const extendedLog: debug1.Debugger = log.extend('extended');
|
2018-10-04 17:31:25 +00:00
|
|
|
extendedLog("Testing this is also an IDebugger.");
|
|
|
|
|
|
2019-01-29 06:05:37 +00:00
|
|
|
const extendedWithCustomDelimiter: debug1.Debugger = log.extend('with-delim', '.');
|
2019-01-27 09:41:49 +00:00
|
|
|
extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
|
2019-03-28 00:27:38 +00:00
|
|
|
|
|
|
|
|
debug2.log = console.log.bind(console);
|
|
|
|
|
const anotherLogger = debug2("DefinitelyTyped:error");
|
|
|
|
|
anotherLogger("This should be printed to stdout");
|