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


TypeScript Logger.error方法代码示例

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


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

示例1: getClient

export async function call<Params, Res>(
  store: Store,
  logger: Logger,
  rc: RequestCreator<Params, Res>,
  params: Params,
  setup?: SetupFunc
): Promise<Res> {
  const client = await getClient(store, logger);

  try {
    logger.debug(`🙏 ${rc({} as any)(client).method}`);
    return await client.call(rc, params, setup);
  } catch (e) {
    if (isCancelled(e)) {
      // nvm
    } else if (isAborted(e)) {
      // nvm
    } else {
      logger.error(`Caught butler error:`);
      if (isInternalError(e)) {
        const ed = getRpcErrorData(e);
        if (ed) {
          logger.error(`butler version: ${ed.butlerVersion}`);
          logger.error(`Golang stack:\n${ed.stack}`);
        }
        logger.error(`JavaScript stack: ${e.stack}`);
      } else {
        logger.error(`${e.message}`);
      }
    }
    throw e;
  }
}
开发者ID:itchio,项目名称:itch,代码行数:33,代码来源:utils.ts

示例2: setImmediate

 setImmediate(() => {
   try {
     f();
   } catch (e) {
     this.logger.error(`In scheduled stateChange: ${e.stack}`);
   }
 });
开发者ID:itchio,项目名称:itch,代码行数:7,代码来源:watcher.ts

示例3: async

    this.addWatcher(actionName, async (store, action) => {
      let rs = store.getState();
      if (rs === oldRs) {
        return;
      }
      oldRs = rs;

      if (!selector) {
        const schedule: Schedule = f => {
          setImmediate(() => {
            try {
              f();
            } catch (e) {
              this.logger.error(`In scheduled stateChange: ${e.stack}`);
            }
          });
        };
        schedule.dispatch = (action: Action<any>) => {
          schedule(() => store.dispatch(action));
        };
        selector = makeSelector(store, schedule);
      }

      try {
        selector(rs);
      } catch (e) {
        this.logger.error(`In state selector: ${e.stack}`);
      }
    });
开发者ID:itchio,项目名称:itch,代码行数:29,代码来源:watcher.ts

示例4: 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

示例5: err

function err(logger: Logger, e: Error, action: Action<any>) {
  if (isCancelled(e)) {
    console.warn(`reactor for ${action.type} was cancelled`);
  } else {
    const actionName = (action || { type: "?" }).type;
    const errorStack = e.stack || e;
    const msg = `while reacting to ${actionName}: ${errorStack}`;
    logger.error(msg);
  }
}
开发者ID:itchio,项目名称:itch,代码行数:10,代码来源:route.ts

示例6: 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

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