How to use diagnostics - 10 common examples

To help you get started, we’ve selected a few diagnostics 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 godaddy / ekke / native / screen.js View on Github external
import createRenderer from '../components/renderer';
import { AppRegistry } from 'react-native';
import diagnostics from 'diagnostics';
import { events } from './bridge';
import Ultron from 'ultron';

//
// Dedicated screen logger.
//
const debug = diagnostics('ekke:screen');

/**
 * The Screen class allows us to manage what is current presented on the
 * device's screen. It could be the original application that the developer
 * is working on, or our custom Ekke test runner. This class makes it all
 * possible and orchestrates all the required API calls to hack this
 * together.
 *
 * @constructor
 * @public
 */
class Screen {
  constructor(rootTag) {
    this.events = new Ultron(events);   // Created a managed EventEmitter.
    this.previous = this.discover();    // Name of the current mounted app.
    this.rootTag = rootTag;             // Reference to the rootTag
github godaddy / asset-system / packages / provider / provider / remote.js View on Github external
import diagnostics from 'diagnostics';
import Queue from 'queueback';

//
// Setup our debug util.
//
const debug = diagnostics('asset:provider:remote');

//
// Cache and Queue setup to prevent duplicate HTTP requests.
//
const queue = new Queue();
const cache = {};

/**
 * Fetch a given resource and parse it's outcome, store it, and send it to
 * all other requests that were waiting for the same response.
 *
 * @param {Object} options Request options.
 * @param {AssetParser} parser AssetParser instance
 * @param {Function} fn Error first completion callback
 * @returns {Undefined|Boolean} Indication of cached, queued or loaded response.
 * @public
github godaddy / asset-system / packages / parser / asset.js View on Github external
import { Pass } from 'passing-through';
import diagnostics from 'diagnostics';
import transform from './transform';
import React from 'react';
import { G } from 'svgs';

//
// Setup our debug util.
//
const debug = diagnostics('asset:parser:asset');

/**
 * Representation of a single Asset of an bundle.
 *
 * @constructor
 * @param {Object} data The data structure.
 * @param {Object} hooks Methods that alter the SVG on the fly.
 * @param {String} version Version number of the specification.
 * @public
 */
export default class Asset {
  constructor(data, hooks = {}, version) {
    this.version = version;
    this.hooks = hooks;
    this.data = data;
github godaddy / asset-system / packages / bundle / index.js View on Github external
import dimensions from 'asset-dimensions';
import diagnostics from 'diagnostics';
import * as AP from 'asset-parser';
import EventEmitter from 'events';
import { load } from 'cheerio';
import walker from './walker';
import async from 'async';
import Svgo from 'svgo';
import path from 'path';
import fs from 'fs';

//
// Setup our debug util.
//
const debug = diagnostics('asset:bundle');

/**
 * Bundle it up.
 *
 * @param {Array} paths The files to include in the bundle.
 * @param {Object} config Configuration.
 * @constructor
 * @public
 */
class Bundle extends EventEmitter {
  constructor(paths, config = {}) {
    super();

    this.configure(config);
    this.specification = AP.version || '0.1.0';
    this.paths = paths;
github godaddy / ekke / native / runner.js View on Github external
import { tasked, destroyer } from '../native/utils';
import Evaluator from '../native/evaluator';
import uncaught from '../native/uncaught';
import intercept from '../native/console';
import diagnostics from 'diagnostics';
import failure from 'failure';

//
// Setup our debug instance.
//
const debug = diagnostics('ekke:runner');

/**
 * Run the metro bundle, tests, plugins, everything. Basically the heart of
 * the project.
 *
 * @param {Screen} screen Screen API.
 * @param {Subway} subway Subway API.
 * @param {Object} config Configuration.
 * @param {Plugin} plugin Plugin API.
 * @public
 */
async function runner({ screen, subway, config, plugin }) {
  const eva = new Evaluator(subway);

  const { destroy, teardown } = destroyer(async function destoryed() {
    debug('tearing down the whole test suite');
github godaddy / ekke / native / plugin.js View on Github external
import EventEmitter from 'eventemitter3';
import diagnostics from 'diagnostics';
import shrubbery from 'shrubbery';
import { events } from './bridge';
import failure from 'failure';
import ms from 'millisecond';
import yeast from 'yeast';

//
// Create our debugging instance.
//
const debug = diagnostics('ekke:plugin');

/**
 * Orchestrate plugins.
 *
 * @param {Subway} subway Our communication class.
 * @public
 */
class Plugin extends EventEmitter {
  constructor(subway) {
    super();

    this.modifiers = new Map();     // Registered modifiers.
    this.inflight = new Map();      // Bridge requests that are awaiting reponse
    this.registry = new Map();      // Registry for our plugin functions.
    this.cleanup = [];              // Function to execute on reset.
    this.subway = subway;
github godaddy / asset-system / packages / parser / transform.js View on Github external
import { Through } from 'passing-through';
import diagnostics from 'diagnostics';
import * as svgs from 'svgs';
import React from 'react';

//
// Setup our debug util.
//
const debug = diagnostics('asset:parser:transform');

/**
 * Figure out the type of what.
 *
 * @param {Mixed} what Thing we need figure the type of.
 * @returns {String} The type of what.
 * @private
 */
function type(what) {
  return Object.prototype.toString.call(what).slice(8, -1).toLowerCase();
}

/**
 * Transforms the SVG data in to actual Svgs SVG elements.
 *
 * @param {Object} data The SVG data for a single asset.
github godaddy / asset-system / packages / provider / provider / index.js View on Github external
import { Component, Children } from 'react';
import AssetParser from 'asset-parser';
import diagnostics from 'diagnostics';
import { ProSumer } from '../context';
import PropTypes from 'prop-types';
import remote from './remote';
import React from 'react';

//
// Setup our debug util.
//
const debug = diagnostics('asset:provider');

//
// Our actual Parser and Fetcher logic
//
export const parser = new AssetParser();

/**
 * Various of readyStates of the Provider.
 *
 * @type {Number}
 * @private
 */
export const READYSTATES = {
  NOPE: 1,
  LOADING: 2,
  LOADED: 3
github godaddy / ekke / native / uncaught.js View on Github external
import diagnostics from 'diagnostics';
import once from 'one-time';

//
// Dedicated uncaught exception logger.
//
const debug = diagnostics('ekke:uncaught');

/**
 * Adds an uncaught exception handler.
 *
 * @param {Function} fn Function to execute when an uncaughtException handles.
 * @returns {Function} Function to restore the error handler.
 * @public
 */
function capture(fn) {
  const old = ErrorUtils.getGlobalHandler();

  /**
   * A function that will restore the error handler to it's original state
   * as we've found it, we only want to restore it once or we could accidentally
   * override another error handler.
   *
github godaddy / ekke / native / subway.js View on Github external
import stringify from 'json-stringify-safe';
import EventEmitter from 'eventemitter3';
import { Platform } from 'react-native';
import diagnostics from 'diagnostics';
import qs from 'querystringify';
import Timers from 'tick-tock';
import failure from 'failure';
import ms from 'millisecond';
import once from 'one-time';
import yeast from 'yeast';

//
// Dedicated subway debugger.
//
const debug = diagnostics('ekke:subway');

/**
 * Subway, our API client for Metro.
 *
 * @constructor
 * @param {String} hostname The hostname of the service.
 * @param {Number} port The port number of the host.
 * @public
 */
class Subway extends EventEmitter {
  constructor(hostname, port) {
    super();

    //
    // The entry path, that stores our super secret, test-specific endpoint
    // on our Metro bundler.

diagnostics

Tools for debugging your node.js modules and event loop

MIT
Latest version published 5 years ago

Package Health Score

66 / 100
Full package analysis