How to use @boost/debug - 10 common examples

To help you get started, we’ve selected a few @boost/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 milesj / boost / packages / core / src / testUtils.ts View on Github external
...options,
  });

  // Register default plugins
  if (injectPlugin) {
    // @ts-ignore Ignore this for convenience
    tool.registerPlugin('plugin', Plugin);
  }

  // Stub out standard objects
  tool.args = stubArgs();
  tool.config = stubToolConfig(config);
  tool.package = stubPackageJson();

  // Stub out methods
  tool.debug = mockDebugger();

  // TODO Remove in 2.0
  // @ts-ignore
  tool.createDebugger = mockDebugger;

  // @ts-ignore Allow private access to avoid loaders
  tool.initialized = true;

  return tool;
}
github milesj / boost / packages / core / src / Tool.ts View on Github external
settingsBlueprint: object(),
        workspaceRoot: string(),
      },
      {
        name: this.constructor.name,
      },
    );

    this.appPath = Path.resolve(this.options.appPath);
    this.rootPath = Path.resolve(this.options.root);

    // Set environment variables
    env('DEBUG_GLOBAL_NAMESPACE', this.options.appName);

    // Core debugger, logger, and translator for the entire tool
    this.debug = createDebugger('core');

    this.log = createLogger();

    this.msg = createTranslator(
      ['app', 'errors'],
      [
        new Path(__dirname, '../res'),
        this.appPath.append('res'),
        // TODO Remove in 2.0
        this.appPath.append('resources'),
      ],
      {
        // TODO Change to yaml in 2.0
        resourceFormat: 'json',
      },
    );
github milesj / boost / packages / core / src / Console.ts View on Github external
constructor(tool: Tool, /* test only */ testWriters: typeof BOUND_WRITERS = BOUND_WRITERS) {
    super();

    this.debug = createDebugger('console');
    this.tool = tool;
    this.writers = testWriters;

    this.onError = new Event('error');
    this.onRoutine = new Event('routine');
    this.onRoutines = new Event('routines');
    this.onStart = new Event('start');
    this.onStop = new Event('stop');
    this.onTask = new Event('task');
    this.onTasks = new Event('tasks');

    // istanbul ignore next
    if (process.env.NODE_ENV !== 'test') {
      process
        .on('SIGINT', this.handleSignal)
        .on('SIGTERM', this.handleSignal)
github milesj / boost / packages / pipeline / src / Pipeline.ts View on Github external
constructor(context: Ctx, value?: Input, options?: Options) {
    super(options);

    this.context = context;
    this.debug = createDebugger(kebabCase(this.constructor.name));

    // This is technically invalid, but we want to allow optional values.
    // Luckily the input type defaults to `unknown`, so it forces consumers to validate.
    // @ts-ignore
    this.value = value;

    this.debug('Instantiating pipeline');
  }
github milesj / boost / packages / core / src / testUtils.ts View on Github external
export function mockRoutine = TestTool>(
  tool: T,
  key: string = 'key',
  title: string = 'Title',
): Routine {
  const routine = new MockRoutine(key, title);

  routine.tool = tool;
  routine.debug = mockDebugger();

  return routine;
}
github milesj / boost / packages / core / src / Routine.ts View on Github external
constructor(key: string, title: string, options?: Options) {
    super(title, (context, value) => this.execute(context, value));

    if (!key || typeof key !== 'string') {
      throw new Error('Routine key must be a valid unique string.');
    }

    this.key = key;
    this.options = optimal({ ...options }, this.blueprint(predicates), {
      name: this.constructor.name,
    });

    this.debug = createDebugger(['routine', this.key]);
    this.onCommand = new Event('command');
    this.onCommandData = new Event('command.data');
  }
github milesj / boost / packages / plugin / src / Loader.ts View on Github external
constructor(manager: Manager) {
    this.manager = manager;
    this.debug = createDebugger([manager.singularName, 'loader']);
  }
github milesj / boost / packages / core / src / ConfigLoader.ts View on Github external
constructor(tool: Tool) {
    this.debug = createDebugger('config-loader');
    this.tool = tool;
  }
github milesj / boost / packages / plugin / src / Registry.ts View on Github external
import kebabCase from 'lodash/kebabCase';
import pluralize from 'pluralize';
import { createDebugger } from '@boost/debug';
import { RuntimeError, color } from '@boost/internal';
import Loader from './Loader';
import { PluginType, Pluggable, LoadResult } from './types';
import formatModuleName from './formatModuleName';

export default class Registry {
  readonly debug = createDebugger('plugin-registry');

  private plugins: { [K in keyof Types]?: LoadResult[] } = {};

  private toolName: string;

  private types: { [K in keyof Types]?: PluginType } = {};

  constructor(toolName: string) {
    this.toolName = kebabCase(toolName);
  }

  /**
   * Return a plugin loader for the defined type.
   */
  createLoader(typeName: K): Loader {
    return new Loader(this.getRegisteredType(typeName), this.toolName);
github milesj / boost / packages / plugin / src / Manager.ts View on Github external
constructor(projectName: string, typeName: string, options: ManagerOptions) {
    super(options);

    this.projectName = kebabCase(projectName);
    this.singularName = kebabCase(typeName);
    this.pluralName = pluralize(this.singularName);
    this.debug = createDebugger([this.singularName, 'manager']);
    this.loader = new Loader(this);

    this.debug('Creating new plugin type: %s', color.pluginName(typeName));
  }

@boost/debug

Lightweight debugging and crash reporting.

MIT
Latest version published 9 months ago

Package Health Score

61 / 100
Full package analysis