当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Log.extend方法代码示例

本文整理汇总了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`);
    });
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:20,代码来源:test-log.ts

示例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,
);
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:31,代码来源:background.ts


注:本文中的lib/classes/log.Log.extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。