How to use the debug.formatters 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 jdiaz5513 / capnp-ts / packages / capnp-ts / src / util.ts View on Github external
if (n) s += s;
  } while (n);

  return out;
}

// Set up custom debug formatters.

/* tslint:disable:no-string-literal */
/* istanbul ignore next */
initTrace.formatters["h"] = (v: any) => v.toString("hex");
/* istanbul ignore next */
initTrace.formatters["x"] = (v: any) => `0x${v.toString(16)}`;
/* istanbul ignore next */
initTrace.formatters["a"] = (v: any) => `0x${pad(v.toString(16), 8)}`;
/* istanbul ignore next */
initTrace.formatters["X"] = (v: any) => `0x${v.toString(16).toUpperCase()}`;
/* tslint:enable:no-string-literal */
github sirap-group / generate-swap-project / src / lib / utils / Logger.js View on Github external
import inspect from 'prettier-inspect'
import debug from 'debug'

const log = ::console.log
const logErr = ::console.error

debug.formatters.i = v => inspect(v)

export default class Logger {
  constructor (name) {
    this._info = debug(`${name}:INFO`)
    this._warn = debug(`${name}:WARN`)
    this._debug = debug(`${name}:DEBUG`)
    this._error = debug(`${name}:ERROR`)

    this._info.log = log
    this._warn.log = log
    this._debug.log = log
    this._error.log = logErr
  }

  info () {
    ::this._info(...arguments)
github latysheff / node-sctp / lib / endpoint.js View on Github external
const crypto = require('crypto')
const EventEmitter = require('events').EventEmitter
const debug = require('debug')

const transport = require('./transport')
const Packet = require('./packet')
const Chunk = require('./chunk')
const Association = require('./association')
const defs = require('./defs')

debug.formatters.h = v => {
  return v.toString('hex')
}

class Endpoint extends EventEmitter {
  constructor (options) {
    super()
    options = options || {}
    this.ootb = options.ootb
    this.localPort = options.localPort
    if (options.localAddress && options.localAddress.length > 0) {
      this.localAddress = options.localAddress
      this.localActiveAddress = options.localAddress[0]
    }

    this.udpTransport = options.udpTransport
github ef4 / ember-auto-import / ts / analyzer.ts View on Github external
import Plugin, { Tree } from 'broccoli-plugin';
import walkSync from 'walk-sync';
import { unlinkSync, rmdirSync, mkdirSync, readFileSync, removeSync } from 'fs-extra';
import FSTree from 'fs-tree-diff';
import makeDebug from 'debug';
import { Pipeline, File } from 'babel-core';
import { parse } from 'babylon';
import { join, extname } from 'path';
import { isEqual, flatten } from 'lodash';
import Package from './package';
import symlinkOrCopy from 'symlink-or-copy';

makeDebug.formatters.m = modules => {
  return JSON.stringify(
    modules.map(m => ({
      specifier: m.specifier,
      path: m.path,
      isDynamic: m.isDynamic,
      package: m.package.name
    })),
    null,
    2
  );
};

const debug = makeDebug('ember-auto-import:analyzer');

export interface Import {
  path: string;
github twilio-labs / twilio-run / src / utils / debug.ts View on Github external
debug.formatters.r = function redactedFormatterSameline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, allPropertiesRedactor);
  }
  return debug.formatters.o.bind(debug)(v);
};
github yjs / yjs / src / y.js View on Github external
import extendStruct from './Struct.js'
import extendUtils from './Utils.js'
import extendMemory from './y-memory.js'
import debug from 'debug'
import { formatYjsMessage, formatYjsMessageType } from './MessageHandler.js'

extendConnector(Y)
extendPersistence(Y)
extendDatabase(Y)
extendTransaction(Y)
extendStruct(Y)
extendUtils(Y)
extendMemory(Y)

Y.debug = debug
debug.formatters.Y = formatYjsMessage
debug.formatters.y = formatYjsMessageType

var requiringModules = {}

Y.requiringModules = requiringModules

Y.extend = function (name, value) {
  if (arguments.length === 2 && typeof name === 'string') {
    if (value instanceof Y.utils.CustomTypeDefinition) {
      Y[name] = value.parseArguments
    } else {
      Y[name] = value
    }
    if (requiringModules[name] != null) {
      requiringModules[name].resolve()
      delete requiringModules[name]
github twilio-labs / twilio-run / src / utils / debug.ts View on Github external
debug.formatters.p = function protectedFormatterSameline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, generalRedactor);
  }

  return debug.formatters.o.bind(debug)(v);
};

debug.formatters.R = function redactedFormatterMultiline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, allPropertiesRedactor);
  }
  return debug.formatters.O.bind(debug)(v);
};

debug.formatters.r = function redactedFormatterSameline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, allPropertiesRedactor);
  }
  return debug.formatters.o.bind(debug)(v);
};
github inkandswitch / capstone / src / node_modules / hypermerge / index.ts View on Github external
import Queue from "capstone/Queue"
import * as JsonBuffer from "../../logic/JsonBuffer"
import * as Base58 from "bs58"
import * as crypto from "hypercore/lib/crypto"
import { hypercore, Feed, Peer, discoveryKey } from "./hypercore"
import * as Backend from "automerge/backend"
import { Change } from "automerge/backend"
import { BackendManager } from "./backend"
import { FrontendManager } from "./frontend"
import * as Debug from "debug"

export { Feed, Peer } from "./hypercore"
export { Patch, Doc, EditDoc, ChangeFn } from "automerge/frontend"
export { BackendManager, FrontendManager }

Debug.formatters.b = Base58.encode

const HypercoreProtocol: Function = require("hypercore-protocol")
const ram: Function = require("random-access-memory")
const raf: Function = require("random-access-file")

const log = Debug("hypermerge")

export interface Keys {
  publicKey: Buffer
  secretKey?: Buffer
}

export interface FeedData {
  actorId: string
  writable: Boolean
  changes: Change[]
github amqp / rhea / lib / log.js View on Github external
* You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';

var debug = require('debug');

if (debug.formatters) {
    debug.formatters.h = function (v) {
        return v.toString('hex');
    };
}

module.exports = {
    'config' : debug('rhea:config'),
    'frames' : debug('rhea:frames'),
    'raw' : debug('rhea:raw'),
    'reconnect' : debug('rhea:reconnect'),
    'events' : debug('rhea:events'),
    'message' : debug('rhea:message'),
    'flow' : debug('rhea:flow'),
    'io' : debug('rhea:io')
};
github twilio-labs / twilio-run / src / utils / debug.ts View on Github external
obj: object,
  redactor: typeof generalRedactor
) {
  const copiedObject = copyObject(obj);
  return redactor(copiedObject);
}

debug.formatters.P = function protectedFormatterMultiline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, generalRedactor);
  }

  return debug.formatters.O.bind(debug)(v);
};

debug.formatters.p = function protectedFormatterSameline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, generalRedactor);
  }

  return debug.formatters.o.bind(debug)(v);
};

debug.formatters.R = function redactedFormatterMultiline(v: any): string {
  if (typeof v === 'object') {
    v = createRedactedObject(v, allPropertiesRedactor);
  }
  return debug.formatters.O.bind(debug)(v);
};

debug.formatters.r = function redactedFormatterSameline(v: any): string {
  if (typeof v === 'object') {