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


TypeScript Logger.info方法代码示例

本文整理汇总了TypeScript中common/Logger.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Logger.info方法的具体用法?TypeScript Logger.info怎么用?TypeScript Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common/Logger.Logger的用法示例。


在下文中一共展示了Logger.info方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: onMessage

 private onMessage(logger: Logger, msg: ISM) {
   if (msg.type === "no-update-available") {
     this.stage("idle");
   } else if (msg.type === "installing-update") {
     this.stage("download");
   } else if (msg.type === "update-failed") {
     const pp = msg.payload as ISM_UpdateFailed;
     logger.error(`Self-update failed: ${pp.message}`);
   } else if (msg.type === "update-ready") {
     const pp = msg.payload as ISM_UpdateReady;
     logger.info(`Version ${pp.version} is ready to be used.`);
     this.store.dispatch(
       actions.packageNeedRestart({
         name: this.name,
         availableVersion: pp.version,
       })
     );
   } else if (msg.type === "progress") {
     const pp = msg.payload as ISM_Progress;
     this.store.dispatch(
       actions.packageProgress({
         name: this.name,
         progressInfo: pp,
       })
     );
   } else if (msg.type === "log") {
     const pp = msg.payload as ISM_Log;
     logger.info(`> ${pp.message}`);
   }
 }
开发者ID:itchio,项目名称:itch,代码行数:30,代码来源:self-package.ts

示例2: async

        client.on(messages.LaunchRunning, async () => {
          logger.info("Now running!");
          ctx.emitProgress({ progress: 1, stage: "run" });

          if (preferences.preventDisplaySleep) {
            powerSaveBlockerId = powerSaveBlocker.start(
              "prevent-display-sleep"
            );
          }
        });
开发者ID:HorrerGames,项目名称:itch,代码行数:10,代码来源:perform-launch.ts

示例3: async

 convo.on(messages.Log, async ({ level, message }) => {
   switch (level) {
     case "debug":
       logger.debug(message);
       break;
     case "info":
       logger.info(message);
       break;
     case "warning":
       logger.warn(message);
       break;
     case "error":
       logger.error(message);
       break;
     default:
       logger.info(`[${level}] ${message}`);
       break;
   }
 });
开发者ID:itchio,项目名称:itch,代码行数:19,代码来源:utils.ts

示例4: Error

      cb: res => {
        logger.info(`HTTP ${res.statusCode} ${url}`);
        if (!/^2/.test("" + res.statusCode)) {
          throw new Error(`HTTP ${res.statusCode} ${url}`);
        }

        const contentLengthHeader = res.headers["content-length"];
        if (!isEmpty(contentLengthHeader)) {
          totalSize = parseInt(contentLengthHeader[0], 10);
        }
      },
开发者ID:HorrerGames,项目名称:itch,代码行数:11,代码来源:download.ts

示例5: onProgress

 progressStream.on("progress", info => {
   onProgress({
     progress: info.percentage / 100,
     eta: info.eta,
     bps: info.speed,
     doneBytes: (info.percentage / 100) * totalSize,
     totalBytes: totalSize,
   });
   logger.info(
     `${info.percentage.toFixed(1)}% done, eta ${info.eta.toFixed(
       1
     )}s @ ${fileSize(info.speed)}/s`
   );
 });
开发者ID:itchio,项目名称:itch,代码行数:14,代码来源:download.ts

示例6: performLaunch

export async function performLaunch(
  ctx: Context,
  logger: Logger,
  cave: Cave,
  game: Game
) {
  ctx.emitProgress({ progress: -1, stage: "configure" });

  const { store } = ctx;
  const taskId = ctx.getTaskId();
  store.dispatch(
    actions.taskProgress({
      id: taskId,
      progress: -1,
      stage: "prepare",
    })
  );

  // TODO: have butler check morphing and queue a heal if needed
  const { appVersion } = store.getState().system;
  logger.info(`itch ${appVersion} launching '${game.title}' (#${game.id})`);

  const { preferences } = store.getState();
  const prereqsDir = paths.prereqsPath();

  // TODO: extract that to another module
  let prereqsModal: ITypedModal<any, any>;
  let prereqsStateParams: IPrereqsStateParams;

  function closePrereqsModal() {
    if (!prereqsModal) {
      return;
    }

    store.dispatch(
      actions.closeModal({
        window: "root",
        id: prereqsModal.id,
      })
    );
    prereqsModal = null;
  }

  let powerSaveBlockerId = null;

  let client: Client;
  let cancelled = false;

  await ctx.withStopper({
    work: async () => {
      client = new Client(store.getState().butlerd.endpoint);
      await client.connect();
      try {
        setupClient(client, logger, ctx);

        client.on(messages.PickManifestAction, async ({ actions }) => {
          const index = await pickManifestAction(store, actions, game);
          return { index };
        });

        client.on(messages.HTMLLaunch, async params => {
          return await performHTMLLaunch({
            ctx,
            logger,
            game,
            params,
          });
        });

        client.on(messages.ShellLaunch, async ({ itemPath }) => {
          shell.openItem(itemPath);
          return {};
        });

        client.on(messages.URLLaunch, async ({ url }) => {
          store.dispatch(actions.navigate({ window: "root", url }));
          return {};
        });

        client.on(messages.PrereqsStarted, async ({ tasks }) => {
          prereqsStateParams = {
            gameTitle: game.title,
            tasks: {},
          };

          for (const name of Object.keys(tasks)) {
            const task = tasks[name];
            prereqsStateParams.tasks[name] = {
              fullName: task.fullName,
              order: task.order,
              status: PrereqStatus.Pending,
              progress: 0,
              eta: 0,
              bps: 0,
            };
          }

          prereqsModal = modalWidgets.prereqsState.make({
            window: "root",
            title: ["grid.item.installing"],
//.........这里部分代码省略.........
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:perform-launch.ts

示例7: downloadToFile

export async function downloadToFile(
  onProgress: (progress: ProgressInfo) => void,
  logger: Logger,
  url: string,
  file: string
) {
  const dir = dirname(file);
  try {
    await sf.mkdirp(dir);
  } catch (e) {
    logger.error(`Could not create ${dir}: ${e.message}`);
  }

  const fileSink = sf.createWriteStream(file, {
    flags: "w",
    mode: 0o777,
    defaultEncoding: "binary",
  }) as WriteStream;
  try {
    let totalSize = 0;

    let progressStream: NodeJS.ReadWriteStream;
    await request(
      "get",
      url,
      {},
      {
        sink: () => {
          progressStream = progress({ length: totalSize, time: 500 });
          progressStream.on("progress", info => {
            onProgress({
              progress: info.percentage / 100,
              eta: info.eta,
              bps: info.speed,
              doneBytes: (info.percentage / 100) * totalSize,
              totalBytes: totalSize,
            });
            logger.info(
              `${info.percentage.toFixed(1)}% done, eta ${info.eta.toFixed(
                1
              )}s @ ${fileSize(info.speed)}/s`
            );
          });
          progressStream.pipe(fileSink);
          return progressStream;
        },
        cb: res => {
          logger.info(`HTTP ${res.statusCode} ${url}`);
          if (!/^2/.test("" + res.statusCode)) {
            const e = new Error(`HTTP ${res.statusCode} ${url}`) as HTTPError;
            e.httpStatusCode = res.statusCode;
            throw e;
          }

          const contentLengthHeader = res.headers["content-length"];
          if (!isEmpty(contentLengthHeader)) {
            totalSize = parseInt(contentLengthHeader[0], 10);
          }
        },
      }
    );
    await sf.promised(fileSink);

    const stats = await sf.lstat(file);
    logger.info(
      `Downloaded ${fileSize(stats.size)} / ${fileSize(totalSize)} (${
        stats.size
      } bytes)`
    );

    if (totalSize !== 0 && stats.size !== totalSize) {
      throw new Error(`download failed (short size) for ${url}`);
    }
  } finally {
    fileSink.end();
  }
}
开发者ID:itchio,项目名称:itch,代码行数:77,代码来源:download.ts


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