本文整理匯總了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,
);