How to use the debug.enabled function in debug

To help you get started, we’ve selected a few debug 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 MitocGroup / recink / components / e2e / src / testcafe / puppeteer-browser-provider.es6 View on Github external
openedPages: {},

  /**
   * Multiple browsers support
   * @type {Boolean}
   */
  isMultiBrowser: false,

  /**
   * Puppeteer initialization options
   * @type {*}
   * @private
   */
  _options: {
    ignoreHTTPSErrors: true,
    headless: !debug.enabled('puppeteer'),
    slowMo: debug.enabled('puppeteer') ? 250 : 0,
    timeout: 60000,
    dumpio: debug.enabled('puppeteer'),

    // avoid issues in Travis
    args: Env.isCI ? [ '--no-sandbox', '--disable-setuid-sandbox' ] : [],
  },

  /**
   * Open new page in browser
   * @param {String} id
   * @param {String} pageUrl
   * @returns {Promise}
   */
  async openBrowser(id, pageUrl) {
    const browser = await puppeteer.launch(this._options);
github khalidx / resource-x / src / cli.ts View on Github external
async function onError (error: any): Promise {
  // If debug is on, log the entire error object, otherwise log just the message
  log('error', debug.enabled('rx:cli') ? error : error.message)
  process.exit(1)
}
github ianstormtaylor / slate / packages / slate-react / src / plugins / react / index.js View on Github external
function ReactPlugin(options = {}) {
  const { placeholder = '' } = options
  const debugEventsPlugin = Debug.enabled('slate:events')
    ? DebugEventsPlugin(options)
    : null
  const debugBatchEventsPlugin = Debug.enabled('slate:batch-events')
    ? DebugBatchEventsPlugin(options)
    : null
  const debugMutationsPlugin = Debug.enabled('slate:mutations')
    ? DebugMutationsPlugin(options)
    : null
  const renderingPlugin = RenderingPlugin(options)
  const commandsPlugin = CommandsPlugin(options)
  const queriesPlugin = QueriesPlugin(options)
  const editorPropsPlugin = EditorPropsPlugin(options)
  const domPlugin = DOMPlugin(options)
  const restoreDomPlugin = RestoreDOMPlugin()

  // Disable placeholder for Android because it messes with reconciliation
  // and doesn't disappear until composition is complete.
  // e.g. In empty, type "h" and autocomplete on Android 9 and deletes all text.
  const placeholderPlugin = IS_ANDROID
    ? null
    : PlaceholderPlugin({
        placeholder,
github ryx / testcafe-browser-provider-nightmare / src / index.js View on Github external
async openBrowser (id, pageUrl) {
        const conf = {
            show:         debug.enabled(),
            openDevTools: debug.enabled(),
        };

        this.nightmareInstances[id] = Nightmare(conf);

        await this.nightmareInstances[id].goto(pageUrl);
    },
github freeCodeCamp / freeCodeCamp / common / app / redux / fetch-challenges-epic.js View on Github external
fetchChallengeCompleted,
  fetchChallengesCompleted,
  fetchNewBlock,
  challengeSelector,
  nextChallengeSelector
} from './';
import {
  isChallengeLoaded,
  fullBlocksSelector
} from '../entities';

import { shapeChallenges } from './utils';
import { types as challenge } from '../routes/Challenges/redux';
import { langSelector } from '../Router/redux';

const isDev = debug.enabled('fcc:*');

function fetchChallengeEpic(actions, { getState }, { services }) {
  return actions::ofType(challenge.onRouteChallenges)
    .filter(({ payload }) => !isChallengeLoaded(getState(), payload))
    .flatMapLatest(({ payload: params }) => {
      const options = {
        service: 'challenge',
        params
      };
      return services.readService$(options)
        .retry(3)
        .map(({ entities, ...rest }) => ({
          entities: shapeChallenges(entities, isDev),
          ...rest
        }))
        .flatMap(({ entities, result, redirect } = {}) => {
github developmentseed / vt-grid / index.js View on Github external
'use strict'

var fs = require('fs')
var os = require('os')
var spawn = require('child_process').spawn
var path = require('path')
var tmp = require('tmp')
var MBTiles = require('mbtiles')
var tileReduce = require('tile-reduce')
var log = require('single-line-log').stderr
var prettyMs = require('pretty-ms')

var debug = require('debug')
var debugLog = debug('vt-grid:main')
var debugEnabled = debug.enabled('vt-grid:main')

if (!debugEnabled) {
  tmp.setGracefulCleanup()
}

module.exports = vtGrid

/**
 * Build a pyramid of aggregated square-grid features.
 *
 * @param {string} output Path to output aggregated mbtiles data
 * @param {string} input Path to the input mbtiles data
 * @param {Object|Array} options Options OR an array of options objects to allow different aggregations/settings for different zoom levels
 * @param {number} options.basezoom The zoom level at which to find the initial data
 * @param {Array} [options.tiles] An array of [z, x, y] tile coordinates to start with
 * @param {Array} [options.bbox] A [w, s, e, n] bbox defining the area to start with
github ipfs / js-ipfs / src / http / index.js View on Github external
async _createGatewayServer (host, port, ipfs) {
    const server = Hapi.server({
      host,
      port,
      routes: {
        cors: true
      }
    })
    server.app.ipfs = ipfs

    await server.register({
      plugin: Pino,
      options: {
        prettyPrint: Boolean(debug.enabled(LOG)),
        logEvents: ['onPostStart', 'onPostStop', 'response', 'request-error'],
        level: debug.enabled(LOG) ? 'debug' : (debug.enabled(LOG_ERROR) ? 'error' : 'fatal')
      }
    })

    server.route(require('./gateway/routes'))

    return server
  }
github silklabs / silk / log / index.js View on Github external
get: function() {
      if (lastCheckedStalenessCounter !== currentStalenessCounter) {
        currentlyEnabled = debug.enabled(prefix);
        lastCheckedStalenessCounter = currentStalenessCounter;
      }
      return currentlyEnabled;
    },
    set: function (val) {
github freeCodeCamp / freeCodeCamp / server / services / challenge.js View on Github external
import debug from 'debug';
import { pickBy } from 'lodash';
import { Observable } from 'rx';

import { cachedMap, getChallenge } from '../utils/map';
import { shapeChallenges } from '../../common/app/redux/utils';

const log = debug('fcc:services:challenge');
const isDev = debug.enabled('fcc:*');

export default function getChallengesForBlock(app) {
  const challengeMap = cachedMap(app.models);
  return {
    name: 'challenge',
    read: function readChallengesForBlock(
        req,
        resource,
        { dashedName, blockName} = {},
        config,
        cb
      ) {
      const getChallengeBlock$ = challengeMap
        .flatMap(({
          result: { superBlocks },
          entities: {
github milesj / boost / packages / core / src / helpers / enableDebug.ts View on Github external
export default function enableDebug(namespace: string) {
  const { DEBUG } = process.env;
  const flag = `${namespace}:*`;

  if (DEBUG) {
    if (DEBUG.includes(flag)) {
      return;
    }

    process.env.DEBUG += `,${flag}`;
  } else {
    process.env.DEBUG = flag;
  }

  debug.enabled(flag);
}