本文整理汇总了TypeScript中lib/classes/log.Log.extend方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Log.extend方法的具体用法?TypeScript Log.extend怎么用?TypeScript Log.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib/classes/log.Log
的用法示例。
在下文中一共展示了Log.extend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("works with extended logs", async function() {
// setup
stubConsoleFn("info");
const spiedFn = console.info as Sinon.SinonSpy & typeof console.info;
const dEnabled = defer<boolean>();
const mainLog = new Log({enabled: false, level: "all"});
mainLog.setEnabled(dEnabled.promise);
const log = mainLog.extend({});
// exercise
mainLog.info("mainLog");
log.info("log");
dEnabled.resolve(true);
await Promise.resolve();
// verify
sinon.assert.calledTwice(spiedFn);
sinon.assert.calledWithExactly(spiedFn, `${C.LOG_PREFIX}[DELAYED] mainLog`);
sinon.assert.calledWithExactly(spiedFn, `${C.LOG_PREFIX}[DELAYED] log`);
});
示例2: Log
*/
import { EweModule } from "app/ewe.module";
import {
StorageMigrationFromXpcom,
} from "controllers/storage-migration-from-xpcom";
import { C } from "data/constants";
import { Connection } from "lib/classes/connection";
import { Log, LogLevel } from "lib/classes/log";
import { getPortFromMasterConnectable } from "lib/utils/connection-utils";
const rootLog = new Log({
enabled: true,
level: LogLevel.ALL,
});
const log = rootLog.extend({name: "ewe"});
const portGetterLog = rootLog.extend({name: "ewe.getPortFromConnectable"});
const portGetterDebugLog = portGetterLog.extend({
enabled: C.LOG_STORAGE_MIGRATION,
});
const promiseLegacyPort = () => getPortFromMasterConnectable(
portGetterLog,
portGetterDebugLog,
browser.runtime,
);
const legacyConnection = new Connection(
C.EWE_CONNECTION_EWE_ID,
rootLog,
C.EWE_CONNECTION_LEGACY_ID,
promiseLegacyPort,
);