How to use the loglevel.warn function in loglevel

To help you get started, we’ve selected a few loglevel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brave / ethereum-remote-client / ui / i18n.js View on Github external
// cross-browser connection to extension i18n API

const chrome = chrome || null
const browser = browser || null
const extension = require('extensionizer')
var log = require('loglevel')
window.log = log
let getMessage

if (extension.i18n && extension.i18n.getMessage) {
  getMessage = extension.i18n.getMessage
} else {
  // fallback function
  log.warn('browser.i18n API not available, calling back to english.')
  const msg = require('../app/_locales/en/messages.json')
  getMessage = function (key, substitutions) {
    if (!msg[key]) {
      log.error(key)
      throw new Error(key)
    }
    let phrase = msg[key].message
    if (substitutions && substitutions.length) {
      phrase = phrase.replace(/\$1/g, substitutions[0])
      if (substitutions.length > 1) {
        phrase = phrase.replace(/\$2/g, substitutions[1])
      }
    }
    return phrase
  }
}
github sulu / sulu / src / Sulu / Bundle / AdminBundle / Resources / js / views / Form / toolbarActions / CopyLocaleToolbarAction.js View on Github external
constructor(
        resourceFormStore: ResourceFormStore,
        form: Form,
        router: Router,
        locales: ?Array,
        options: {[key: string]: mixed},
        parentResourceStore: ResourceStore
    ) {
        const {
            display_condition: displayCondition,
            visible_condition: visibleCondition,
        } = options;

        if (displayCondition) {
            // @deprecated
            log.warn(
                'The "display_condition" option is deprecated since version 2.0 and will be removed. ' +
                'Use the "visible_condition" option instead.'
            );

            if (!visibleCondition) {
                options.visible_condition = displayCondition;
            }
        }

        super(resourceFormStore, form, router, locales, options, parentResourceStore);
    }
github compodoc / compodoc / src-refactored / infrastructure / logging / logger.ts View on Github external
public warn(...args) {
        if (this.silent) {
            return;
        }
        return log.warn(this.format(LEVEL.WARN, ...args));
    }
github antonycourtney / tabli / archive / src / js / bgHelper.js View on Github external
storeRef.update((state) => {
      const tabWindow = state.getTabWindowByChromeId(activeInfo.windowId)
      if (!tabWindow) {
        log.warn('tabs.onActivated: window id not found: ', activeInfo.windowId, activeInfo)
        return state
      }
      const st = tabWindow ? state.handleTabActivated(tabWindow, activeInfo.tabId) : state
      return st
    })
  })
github dhis2 / maintenance-app / src / EditModel / SectionDialog.component.js View on Github external
.catch((err) => {
                log.warn('Failed to save section:', err);
                snackActions.show({
                    message: this.getTranslation('failed_to_save_section'),
                    action: this.getTranslation('ok'),
                });
            });
    }
github brave / ethereum-remote-client / app / scripts / controllers / token-rates.js View on Github external
async updateExchangeRates () {
    if (!this.isActive) { return }
    const contractExchangeRates = {}
    const nativeCurrency = this.currency ? this.currency.state.nativeCurrency.toLowerCase() : 'eth'
    const pairs = this._tokens.map(token => token.address).join(',')
    const query = `contract_addresses=${pairs}&vs_currencies=${nativeCurrency}`
    if (this._tokens.length > 0) {
      try {
        const response = await fetch(`https://api.coingecko.com/api/v3/simple/token_price/ethereum?${query}`)
        const prices = await response.json()
        this._tokens.forEach(token => {
          const price = prices[token.address.toLowerCase()] || prices[ethUtil.toChecksumAddress(token.address)]
          contractExchangeRates[normalizeAddress(token.address)] = price ? price[nativeCurrency] : 0
        })
      } catch (error) {
        log.warn(`MetaMask - TokenRatesController exchange rate fetch failed.`, error)
      }
    }
    this.store.putState({ contractExchangeRates })
  }
github brave / ethereum-remote-client / ui / app / helpers / utils / token-util.js View on Github external
async function getSymbolFromContract (tokenAddress) {
  const token = util.getContractAtAddress(tokenAddress)

  try {
    const result = await token.symbol()
    return result[0]
  } catch (error) {
    log.warn(`symbol() call for token at address ${tokenAddress} resulted in error:`, error)
  }
}
github woleet / woleet.id-server / server / src / database / upgrade.ts View on Github external
async function upgrade12(sequelize) {
  log.warn('Checking for update of the "enrollments" model...');
  await ServerConfig.model.sync();
  const cfg = await ServerConfig.getById(CONFIG_ID);
  if (!cfg) {
    return;
  }

  let enrollmentExist = false;
  try {
    await sequelize.query(`SELECT * FROM "enrollments";`);
    enrollmentExist = true;
  } catch {
  }

  const { config } = cfg.toJSON();
  if (config.version < 12) {
    if (enrollmentExist) {
github woleet / woleet.id-server / server / src / database / upgrade.ts View on Github external
async function upgrade7(sequelize) {
  log.warn('Checking for update of the "users" model...');
  await ServerConfig.model.sync();
  const cfg = await ServerConfig.getById(CONFIG_ID);
  if (!cfg) {
    return;
  }

  const { config } = cfg.toJSON();
  if (config.version < 7) {
    log.warn('Need to add "tokenResetPassword" column to the "users" table');
    const tokenResetPassword = await sequelize.query(`ALTER TABLE "users" ADD COLUMN "tokenResetPassword" VARCHAR;`);
    log.debug(tokenResetPassword);
    await ServerConfig.update(CONFIG_ID, { config: Object.assign(config, { version: 7 }) });
  }
}
github woleet / woleet.id-server / server / src / database / upgrade.ts View on Github external
return;
  }

  const { config } = cfg.toJSON();
  if (config.version < 8) {
    doPostUpgrade8 = true;
    log.warn('Need to add "holder" column to the "key" table');
    const holder = await sequelize.query(`ALTER TABLE "keys" ADD COLUMN "holder" VARCHAR;`);
    log.debug(holder);
    log.warn('Need to change "mnemonicEntropy" column to the "key" table');
    const mnemonicEntropy = await sequelize.query(`ALTER TABLE "keys" ALTER COLUMN "mnemonicEntropy" DROP NOT NULL;`);
    log.debug(mnemonicEntropy);
    log.warn('Need to change "mnemonicEntropyIV" column to the "key" table');
    const mnemonicEntropyIV = await sequelize.query(`ALTER TABLE "keys" ALTER COLUMN "mnemonicEntropyIV" DROP NOT NULL;`);
    log.debug(mnemonicEntropyIV);
    log.warn('Need to change "privateKey" column to the "key" table');
    const privateKey = await sequelize.query(`ALTER TABLE "keys" ALTER COLUMN "privateKey" DROP NOT NULL;`);
    log.debug(privateKey);
    log.warn('Need to change "privateKeyIV" column to the "key" table');
    const privateKeyIV = await sequelize.query(`ALTER TABLE "keys" ALTER COLUMN "privateKeyIV" DROP NOT NULL;`);
    log.debug(privateKeyIV);
    await ServerConfig.update(CONFIG_ID, { config: Object.assign(config, { version: 8 }) });
  }
}