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


TypeScript Log.info方法代码示例

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


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

示例1: upsertDistrictAccountsFromContributions

async function upsertDistrictAccountsFromContributions() {
  const districtEntries: DistrictEntry[] = await db.query(
    SQL`SELECT D.address, D.project_id, SUM(D.lands) AS lands,
      (SELECT row_to_json(P.*) FROM projects P WHERE P.id = D.project_id) AS project
        FROM district_entries D
        GROUP BY D.address, D.project_id`
  )

  log.info(`Normalizing ${districtEntries.length} district_entries.`)

  for (const districtEntry of districtEntries) {
    const token = await upsertToken(districtEntry.project)
    if (!token) continue

    const address = districtEntry.address.toLowerCase()

    log.info(`Upserting ${address}`)
    const account = new AccountBalance({
      address,
      token_address: token.get('address'),
      balance: districtEntry.lands.toString()
    })
    await account.upsert({ target: ['address', 'token_address'] })
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:25,代码来源:initDb.ts

示例2: main

export async function main() {
  log.info('Connecting database')
  await db.connect()

  const tokens = await Token.find<TokenAttributes>()

  for (const token of tokens) {
    if (DistrictToken.isValid(token)) continue

    const tokenContract = Object.create(new contracts.ERC20Token(token.address))
    tokenContract.getContractName = () => token.name
    tokenContracts[token.address] = tokenContract
  }

  try {
    log.info(`Connecting to Ethereum Node with ${tokens.map(t => t.name)}`)
    await eth.connect({
      contracts: Object.values(tokenContracts),
      provider: env.get('RPC_URL')
    })

    const delay = env.get('MONITOR_BALANCES_DELAY', '10000')
    log.info(`Using ${delay}ms as delay between updates`)
    await monitorBalances(Number(delay))
  } catch (error) {
    log.info('Whoops, something went wrong')
    log.info(error)

    process.exit()
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:31,代码来源:monitorBalances.ts

示例3: monitorBalances

async function monitorBalances(delay: number) {
  log.info('Updating Account balances')
  await updateAccountBalances()

  log.info('Updating Poll balances')
  await Poll.updateBalances()

  log.info(`Sleeping for ${delay}ms`)
  setTimeout(() => monitorBalances(delay), delay)
}
开发者ID:decentraland,项目名称:agora,代码行数:10,代码来源:monitorBalances.ts

示例4: initializeDatabase

export async function initializeDatabase() {
  const shouldContinue = await cli.confirm(
    `Careful! this will DROP 'projects' and 'district_entries,
  upsert 'account_balances' and a district token.
Do you wish to continue?`
  )
  if (!shouldContinue) return process.exit()

  log.info('Connecting database')
  await db.connect()

  log.info('Initializing state')
  await dropDumps()

  log.info('Restoring district_entries')
  execSync(runpsql('../dumps/districts.20180105.sql'))

  log.info('Restoring projects')
  execSync(runpsql('../dumps/projects.20180105.sql'))

  log.info('Upserting district accounts')
  await upsertDistrictAccountsFromContributions()

  log.info('Dropping leftover tables')
  await dropDumps()

  log.info('All done!')
  process.exit()
}
开发者ID:decentraland,项目名称:agora,代码行数:29,代码来源:initDb.ts

示例5: upsertToken

async function upsertToken(project: Project) {
  if (!project.lookup) return null
  const name = project.name

  log.info(`Upserting Token for ${name}`)
  const token = new DistrictToken(name)
  await token.upsert({ target: ['address'] })

  return token
}
开发者ID:decentraland,项目名称:agora,代码行数:10,代码来源:initDb.ts

示例6: updateAccountBalances

async function updateAccountBalances() {
  const accounts = await AccountBalance.find<AccountBalanceAttributes>()

  for (const account of accounts) {
    const { address, token_address } = account
    const contract = tokenContracts[token_address]

    /*
      Perf improvement to avoid updating contributors account balances
      as they are fixed and only set once. It's important that a proper
      row exist before using the app that map a contributor address to
      it's contributions for each district
      ref: https://github.com/decentraland/agora/pull/126
    */
    if (DistrictToken.isAddress(token_address)) {
      continue
    }

    if (!contract) {
      log.info(`No contract for address ${token_address} in account ${address}`)
      continue
    }

    const contractBalance = await contract.balanceOf(address)
    const balance = eth.utils.fromWei(contractBalance).toString()

    log.info(`Updating Accounts and votes ${address} with balance ${balance}`)
    await Promise.all([
      AccountBalance.update<AccountBalanceAttributes>(
        { balance },
        { address, token_address }
      ),
      Vote.updateBalance(account, balance)
    ])
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:36,代码来源:monitorBalances.ts

示例7: main

async function main() {
  const translation = new Translation()

  const mainTranslations = await translation.fetch(DEFAULT_LOCALE)
  const availableLocales = await getAvailableLocales()

  const mainKeys = Object.keys(mainTranslations)
  let flatMissingTranslations = {}

  for (const locale of availableLocales) {
    const translations = await translation.fetch(locale)
    let requests: Promise<RemoteTranslation>[] = []

    for (const key of mainKeys) {
      if (key in translations) continue

      const defaultText = mainTranslations[key]
      const { textToTranslate, replacedKeys } = replaceTextKeys(defaultText)

      requests.push(
        translate(locale, textToTranslate).then(text => {
          const remoteTranslation: RemoteTranslation = {
            locale,
            key,
            text,
            replacedKeys,
            defaultText
          }
          return remoteTranslation
        })
      )

      if (requests.length > BATCH_SIZE) {
        await updateMissingTranslations(flatMissingTranslations, requests)
        requests = []
      }
    }

    await updateMissingTranslations(flatMissingTranslations, requests)
  }

  await writeTranslations(flatMissingTranslations)
  log.info('Done!')
}
开发者ID:decentraland,项目名称:agora,代码行数:44,代码来源:translate.ts

示例8: updateMissingTranslations

async function updateMissingTranslations(
  flatMissingTranslations: TranslationCache,
  requests: Promise<RemoteTranslation>[]
) {
  const translated = await Promise.all(requests)

  for (let { locale, key, text, replacedKeys, defaultText } of translated) {
    text = restoreTextKeys(text, replacedKeys)

    if (isCapitalized(defaultText) && !isCapitalized(text)) {
      text = capitalize(text)
    }

    if (!flatMissingTranslations[locale]) {
      flatMissingTranslations[locale] = {}
    }
    flatMissingTranslations[locale][key] = text
    log.info(`${locale}(${key}): ${defaultText} -> ${text}`)
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:20,代码来源:translate.ts

示例9: translate

  return text[0].toUpperCase() + text.slice(1)
}

async function translate(lang: string, text: string): Promise<string> {
  /* Result example:
  [
    [
      [ "Debes {sign_in_link} para acceder a esta pรกgina", "You need to {sign_in_link} to access this page", null, null, 3 ]
    ],
    null,
    "en"
  ] */

  const result = await axios.get(
    `https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=${lang}&dt=t&q=${encodeURIComponent(
      text
    )}`
  )
  const translation: string = result.data[0][0][0]
  return translation
}

if (require.main === module) {
  loadEnv()

  BATCH_SIZE = parseInt(env.get('BATCH_SIZE', '10'), 10)
  log.info(`Using ${BATCH_SIZE} as batch size, configurable via BATCH_SIZE`)

  main().catch(error => console.error(error))
}
开发者ID:decentraland,项目名称:agora,代码行数:30,代码来源:translate.ts


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