How to use the @boost/debug.createDebugger function in @boost/debug

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 / 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 / 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));
  }
github milesj / boost / packages / core / src / ModuleLoader.ts View on Github external
constructor(
    tool: Tool,
    typeName: string,
    contract: Constructor | null = null,
    scopes: string[] = [],
  ) {
    this.contract = contract;
    this.debug = createDebugger(`${typeName}-loader`);
    this.scopes = scopes;
    this.tool = tool;
    this.typeName = typeName;
  }

@boost/debug

Lightweight debugging and crash reporting.

MIT
Latest version published 10 months ago

Package Health Score

61 / 100
Full package analysis