How to use the global/window.console function in global

To help you get started, we’ve selected a few global 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 videojs / video.js / src / js / utils / log.js View on Github external
// If there's no console then don't try to output messages, but they will
  // still be stored in history.
  if (!window.console) {
    return;
  }

  // Was setting these once outside of this function, but containing them
  // in the function makes it easier to test cases where console doesn't exist
  // when the module is executed.
  let fn = window.console[type];

  if (!fn && type === 'debug') {
    // Certain browsers don't have support for console.debug. For those, we
    // should default to the closest comparable log.
    fn = window.console.info || window.console.log;
  }

  // Bail out if there's no console or if this type is not allowed by the
  // current logging level.
  if (!fn || !lvl || !lvlRegExp.test(type)) {
    return;
  }

  // IEs previous to 11 log objects uselessly as "[object Object]"; so, JSONify
  // objects and arrays for those less-capable browsers.
  if (stringify) {
    args = args.map(a => {
      if (isObject(a) || Array.isArray(a)) {
        try {
          return JSON.stringify(a);
        } catch (x) {
github videojs / video.js / src / js / utils / create-logger.js View on Github external
// If there's no console then don't try to output messages, but they will
  // still be stored in history.
  if (!window.console) {
    return;
  }

  // Was setting these once outside of this function, but containing them
  // in the function makes it easier to test cases where console doesn't exist
  // when the module is executed.
  let fn = window.console[type];

  if (!fn && type === 'debug') {
    // Certain browsers don't have support for console.debug. For those, we
    // should default to the closest comparable log.
    fn = window.console.info || window.console.log;
  }

  // Bail out if there's no console or if this type is not allowed by the
  // current logging level.
  if (!fn || !lvl || !lvlRegExp.test(type)) {
    return;
  }

  fn[Array.isArray(args) ? 'apply' : 'call'](window.console, args);
};
github videojs / video.js / src / js / utils / log.js View on Github external
// Add the type to the front of the message when it's not "log".
    args.unshift(type.toUpperCase() + ':');
  }

  // Add a clone of the args at this point to history.
  if (history) {
    history.push([].concat(args));
  }

  // Add console prefix after adding to history.
  args.unshift('VIDEOJS:');

  // If there's no console then don't try to output messages, but they will
  // still be stored in history.
  if (!window.console) {
    return;
  }

  // Was setting these once outside of this function, but containing them
  // in the function makes it easier to test cases where console doesn't exist
  // when the module is executed.
  let fn = window.console[type];

  if (!fn && type === 'debug') {
    // Certain browsers don't have support for console.debug. For those, we
    // should default to the closest comparable log.
    fn = window.console.info || window.console.log;
  }

  // Bail out if there's no console or if this type is not allowed by the
  // current logging level.
github iotexproject / iotex-explorer / src / shared / wallet / account-section.tsx View on Github external
const { history, account } = this.props;
    if (!account) {
      return;
    }
    try {
      const txHash = await Token.getToken(tokenAddress).claimAs(
        authMessage,
        account
      );
      // @ts-ignore
      window.console.log(
        `Claimed VITA to ${authMessage.address} at action hash: ${txHash}`
      );
      history.push(`/wallet/smart-contract/interact/${txHash}`);
    } catch (e) {
      window.console.log(e);
      notification.error({
        message: `Failed to claim: ${e}`
      });
    }
  };
github iotexproject / iotex-explorer / src / shared / wallet / account-section.tsx View on Github external
public placeBid = async (amount: string) => {
    const { account, history, bidContractAddress } = this.props;
    if (!account) {
      return;
    }
    try {
      const txHash = await Token.getBiddingToken(bidContractAddress).bid(
        account,
        amount
      );
      // @ts-ignore
      window.console.log(`Place bid ${amount} IOTX at action hash: ${txHash}`);
      history.push(`/wallet/smart-contract/interact/${txHash}`);
    } catch (e) {
      notification.error({
        message: `Failed to bid: ${e}`
      });
    }
  };
github videojs / video.js / src / js / tracks / text-track.js View on Github external
parser.onparsingerror = function(error) {
    errors.push(error);
  };

  parser.onflush = function() {
    track.trigger({
      type: 'loadeddata',
      target: track
    });
  };

  parser.parse(srcContent);
  if (errors.length > 0) {
    if (window.console && window.console.groupCollapsed) {
      window.console.groupCollapsed(`Text Track parsing errors for ${track.src}`);
    }
    errors.forEach((error) => log.error(error));
    if (window.console && window.console.groupEnd) {
      window.console.groupEnd();
    }
  }

  parser.flush();
};
github iotexproject / iotex-antenna / src / plugin / ws.ts View on Github external
this.ws.onopen = (): void => {
      window.console.log("[antenna-ws] connected");
    };
    this.ws.onclose = (): void => {