當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Logger.child函數代碼示例

本文整理匯總了TypeScript中common/Logger.child函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript child函數的具體用法?TypeScript child怎麽用?TypeScript child使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了child函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

 sanityCheck: async (versionPrefix: string) => {
   await spawn({
     ctx: new MinimalContext(),
     logger: rootLogger.child({ name: "itch-setup formula" }),
     command: ospath.join(versionPrefix, "itch-setup"),
     args: ["--version"],
   });
 },
開發者ID:HorrerGames,項目名稱:itch,代碼行數:8,代碼來源:formulas.ts

示例2: function

import { Watcher } from "common/util/watcher";

import { actions } from "common/actions";

import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "abort-task" });

import { getCurrentTasks } from "./as-task-persistent-state";

export default function(watcher: Watcher) {
  watcher.on(actions.abortTask, async (store, action) => {
    const { id } = action.payload;
    const ctx = getCurrentTasks()[id];
    if (ctx) {
      try {
        await ctx.tryAbort();
      } catch (e) {
        logger.warn(`Could not cancel task ${id}: ${e.stack}`);
      }
    }
  });
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:22,代碼來源:abort-task.ts

示例3: function

import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import fs from "fs";
import { dirname } from "path";

import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "explore-cave" });

import * as explorer from "../../os/explorer";

import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);

export default function(watcher: Watcher) {
  watcher.on(actions.exploreCave, async (store, action) => {
    const { caveId } = action.payload;

    const { cave } = await call(messages.FetchCave, { caveId });
    const installFolder = cave.installInfo.installFolder;
    try {
      fs.accessSync(installFolder);
      explorer.open(installFolder);
    } catch (e) {
      explorer.open(dirname(installFolder));
    }
  });
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:27,代碼來源:explore-cave.ts

示例4: function

import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";

import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "queue-cave-uninstall" });

import { promisedModal } from "../modals";

import asTask from "./as-task";
import { modalWidgets } from "renderer/components/modal-widgets/index";

import { performUninstall } from "../downloads/perform-uninstall";

import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);

export default function(watcher: Watcher) {
  watcher.on(actions.queueCaveUninstall, async (store, action) => {
    const { caveId } = action.payload;

    // TODO: figure if we really need that. asTask wants a gameId
    // but do we really need it? how used is asTask anyway?
    const { cave } = await call(messages.FetchCave, { caveId });

    await asTask({
      name: "uninstall",
      gameId: cave.game.id,
      store,
      work: async (ctx, logger) => {
        await performUninstall(logger, caveId);
        store.dispatch(actions.uninstallEnded({}));
開發者ID:HorrerGames,項目名稱:itch,代碼行數:31,代碼來源:queue-cave-uninstall.ts

示例5: function

import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";

import rootLogger, { Logger } from "common/logger";
const logger = rootLogger.child({ name: "queue-game" });

import asTask from "./as-task";

import { IStore } from "common/types/index";
import { Game, Upload, Build } from "common/butlerd/messages";

import { map, isEmpty } from "underscore";
import { modalWidgets } from "renderer/components/modal-widgets/index";

import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);

import { promisedModal } from "../modals";
import { makeInstallErrorModal } from "./make-install-error-modal";
import { makeUploadButton } from "main/reactors/make-upload-button";

export default function(watcher: Watcher) {
  watcher.on(actions.queueGame, async (store, action) => {
    const { game } = action.payload;
    const { caves } = await call(messages.FetchCavesByGameID, {
      gameId: game.id,
    });

    if (isEmpty(caves)) {
      logger.info(
        `No cave for ${game.title} (#${game.id}), attempting install`
開發者ID:HorrerGames,項目名稱:itch,代碼行數:31,代碼來源:queue-game.ts

示例6: updateCommonsNow

import { Watcher } from "common/util/watcher";
import { IStore } from "common/types";

import { indexBy, isEmpty } from "underscore";
import groupIdBy from "common/helpers/group-id-by";

import { actions } from "common/actions";
import { throttle, isEqual } from "underscore";

import rootLogger from "common/logger";
import { messages, withLogger } from "common/butlerd";
const logger = rootLogger.child({ name: "commons" });
const call = withLogger(logger);

async function updateCommonsNow(store: IStore) {
  try {
    await updateCommonsNowThrows(store);
  } catch (e) {
    logger.warn(`While fetching commons: ${e.stack}`);
  }
}

async function updateCommonsNowThrows(store: IStore) {
  if (!store.getState().setup.done) {
    return;
  }

  const { caves, downloadKeys, installLocations } = await call(
    messages.FetchCommons,
    {}
  );
開發者ID:HorrerGames,項目名稱:itch,代碼行數:31,代碼來源:commons.ts

示例7: resolve

import { resolve, join, basename } from "path";
import { app } from "electron";
import spawn from "../spawn";
import * as sf from "../sf";

import { MinimalContext } from "../../context";

import rootLogger, { devNull } from "common/logger";
const logger = rootLogger.child({ name: "shortcut" });

const appFolder = resolve(process.execPath, "..");
const rootFolder = resolve(appFolder, "..");
export const updateExePath = join(rootFolder, "Update.exe");
const exeName = basename(process.execPath);

export async function updateRun(
  ctx: MinimalContext,
  args: string[]
): Promise<void> {
  logger.info(`Update.exe located at = ${updateExePath}`);
  try {
    await spawn.assert({
      command: updateExePath,
      args,
      ctx,
      logger: devNull,
    });
  } catch (err) {
    logger.error(`Running Update failed with ${err.message}`);
  }
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:31,代碼來源:shortcut.ts

示例8:

import { screen } from "electron";
import { createSelector } from "reselect";
import { format as formatUrl, UrlObject } from "url";
import * as path from "path";

import env from "common/env";

import { darkMineShaft } from "common/constants/colors";
import { app, BrowserWindow, BrowserWindowConstructorOptions } from "electron";
import config from "common/util/config";
import * as os from "../os";
import { debounce } from "underscore";

import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "main-window" });

import { actions } from "common/actions";

type AppCommand = "browser-backward" | "browser-forward";

const BOUNDS_CONFIG_KEY = "main_window_bounds";
const MAXIMIZED_CONFIG_KEY = "main_window_maximized";

const macOs = os.platform() === "darwin";

import {
  IRootState,
  IStore,
  INativeWindowState,
  ItchWindowRole,
開發者ID:HorrerGames,項目名稱:itch,代碼行數:30,代碼來源:main-window.ts

示例9: function

import { Watcher } from "common/util/watcher";

import urlParser from "url";

import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "reactors/url" });

import urls from "common/constants/urls";

import { shell } from "electron";

import { actions } from "common/actions";
import { IStore } from "common/types";

import { filter } from "underscore";
import { call, messages } from "common/butlerd";
import { reportIssue } from "main/crash-reporter";
import { isItchioURL } from "common/util/url";

export default function(watcher: Watcher) {
  watcher.on(actions.processUrlArguments, async (store, action) => {
    const { args } = action.payload;
    for (const uri of args) {
      if (isItchioURL(uri)) {
        store.dispatch(actions.handleItchioURI({ uri }));
        break;
      }
    }
  });

  watcher.on(actions.openInExternalBrowser, async (store, action) => {
開發者ID:HorrerGames,項目名稱:itch,代碼行數:31,代碼來源:url.ts

示例10: cancel

import { Client } from "butlerd";

import rootLogger from "common/logger";
import { messages } from "common/butlerd";
const logger = rootLogger.child({ name: "download-driver" });

export enum Phase {
  IDLE,
  STARTING,
  RUNNING,
  CANCELLING,
}

class State {
  private client: Client;
  private phase: Phase;

  constructor() {
    this.phase = Phase.IDLE;
  }

  registerClient(client: Client) {
    this.client = client;
    this.setPhase(Phase.RUNNING);
  }

  async cancel() {
    this.setPhase(Phase.CANCELLING);
    await this.client.call(messages.DownloadsDriveCancel, {});
    this.client = null;
  }
開發者ID:HorrerGames,項目名稱:itch,代碼行數:31,代碼來源:driver-persistent-state.ts


注:本文中的common/Logger.child函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。