How to use the debug.debug 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 sockethub / sockethub / src / config.ts View on Github external
import nconf from 'nconf';
import debug from 'debug';

let config;
const log = debug.debug('sockethub:bootstrap:config');

class Config {
  constructor() {
    log('initializing config');
    // assign config loading priorities (command-line, environment, cfg, defaults)
    nconf.argv({
      'port': {
        alias: 'service.port'
      },
      'host': {
        alias: 'service.host'
      },
      'redis_host': {
        alias: 'redis.host'
      },
      'redis_port': {
github kazupon / vue-i18n-locale-message / src / infuser.ts View on Github external
/* eslint-disable-next-line */
/// 
import { SFCBlock, SFCDescriptor } from 'vue-template-compiler'
import { Locale, MetaLocaleMessage, SFCI18nBlock, SFCFileInfo, FormatOptions } from '../types'

import { escape, reflectSFCDescriptor, parseContent, stringifyContent } from './utils'

import { debug as Debug } from 'debug'
const debug = Debug('vue-i18n-locale-message:infuser')

export default function infuse (basePath: string, sources: SFCFileInfo[], meta: MetaLocaleMessage, options?: FormatOptions): SFCFileInfo[] {
  const descriptors = reflectSFCDescriptor(basePath, sources)

  return descriptors.map(descriptor => {
    return {
      content: generate(meta, descriptor, options),
      path: descriptor.contentPath
    } as SFCFileInfo
  })
}

function generate (meta: MetaLocaleMessage, descriptor: SFCDescriptor, options?: FormatOptions): string {
  const i18nBlocks = meta.components[descriptor.contentPath]
  debug('target i18n blocks\n', i18nBlocks)
github ConsenSys / ethql / packages / core / src / services / eth-service / impl / web3-eth-service.ts View on Github external
import * as Debug from 'debug';
import { GraphQLResolveInfo } from 'graphql';
import * as _ from 'lodash';
import Web3 = require('web3');
import { Hex } from 'web3-utils/types';
import { EthService, fetchHints, FetchHints } from '..';
import { EthqlAccount, EthqlBlock, EthqlLog, EthqlTransaction, LogFilter, TransactionStatus } from '../../../model';

const debug = Debug.debug('ethql:web3');

// Not thrilled about having to copy this in here.
type GetPastLogsOpts = {
  fromBlock?: Hex;
  toBlock?: Hex;
  address?: string;
  topics?: Array;
};

/**
 * A private function to return a prepped param object for the getPastLogs call
 * @param id (Hex) a block number or hex reference
 * @return GetPastLogOpts structure
 */
function formatPastLogsParams(id: Hex): GetPastLogsOpts {
  let hexId = typeof id === 'number' ? Web3.utils.toHex(id) : id;
github zishone / mongover / src / utils / get-logger.ts View on Github external
export function getLogger(fileName: string): Logger {
  const component = fileName.split('.')[0].split(sep).pop();
  return {
    debug: debug(`mongover:debug:${component}`),
    info: debug(`mongover:info:${component}`),
    warn: debug(`mongover:warn:${component}`),
    error: debug(`mongover:error:${component}`),
    cli: debug(`cli:mongover`),
  };
}
github snyk / snyk / src / lib / request / request.ts View on Github external
import { debug as debugModule } from 'debug';
import * as needle from 'needle';
import { parse, format } from 'url';
import * as querystring from 'querystring';
import * as zlib from 'zlib';
import * as config from '../config';
import { getProxyForUrl } from 'proxy-from-env';
import * as ProxyAgent from 'proxy-agent';
import * as analytics from '../analytics';
import { Agent } from 'http';
import { Global } from '../../cli/args';
import { Payload } from './types';
import * as version from '../version';

const debug = debugModule('snyk:req');
const snykDebug = debugModule('snyk');

declare const global: Global;

export = function makeRequest(
  payload: Payload,
): Promise<{ res: needle.NeedleResponse; body: any }> {
  return version().then(
    (versionNumber) =>
      new Promise((resolve, reject) => {
        const body = payload.body;
        let data;

        delete payload.body;

        if (!payload.headers) {
github phaux / node-ffmpeg-stream / src / index.ts View on Github external
import { ChildProcess, spawn } from "child_process"
import { debug } from "debug"
import { createReadStream, createWriteStream, unlink } from "fs"
import { tmpdir } from "os"
import { join } from "path"
import { PassThrough, Readable, Writable } from "stream"
import { promisify } from "util"

const dbg = debug("ffmpeg-stream")
const { FFMPEG_PATH = "ffmpeg" } = process.env
const EXIT_CODES = [0, 255]

function debugStream(stream: Readable | Writable, name: string): void {
  stream.on("error", err => {
    dbg(`${name} error: ${err}`)
  })
  stream.on("data", data => {
    dbg(`${name} data: ${data.length} bytes`)
  })
  stream.on("finish", () => {
    dbg(`${name} finish`)
  })
}

function getTmpPath(prefix = "", suffix = ""): string {
github ConsenSys / ethql / packages / core / src / resolvers / transaction.ts View on Github external
import { EthqlContext } from '@ethql/base';
import * as Debug from 'debug';
import { GraphQLResolveInfo } from 'graphql';
import { EthqlAccount, EthqlBlock, EthqlLog, EthqlTransaction, TransactionStatus } from '../model';
import { DecodedTransaction } from '../services/decoder';

const debug = Debug.debug('ethql:tx-resolve');
async function logs(obj: EthqlTransaction, args, { services }: EthqlContext): Promise {
  debug('obj: %O', obj);
  debug('args: %O', args);
  return obj.logs || services.eth.fetchTransactionLogs(obj, args.filter);
}

function decoded(obj: EthqlTransaction, args, context: EthqlContext): DecodedTransaction {
  return obj.inputData && obj.inputData !== '0x' ? context.services.decoder.decodeTransaction(obj, context) : null;
}

async function block(
  obj: EthqlTransaction,
  args,
  { services }: EthqlContext,
  info: GraphQLResolveInfo,
): Promise {
github kazupon / vue-i18n-locale-message / src / commands / squeeze.ts View on Github external
import { Arguments, Argv } from 'yargs'
import { LocaleMessages, MetaLocaleMessage, Locale } from '../../types'

import { resolve, parsePath, readSFC } from '../utils'
import squeeze from '../squeezer'
import fs from 'fs'

import { debug as Debug } from 'debug'
const debug = Debug('vue-i18n-locale-message:commands:squeeze')

type SqueezeOptions = {
  target: string
  split?: boolean
  output: string
}

export const command = 'squeeze'
export const aliases = 'sqz'
export const describe = 'squeeze locale messages from single-file components'

export const builder = (args: Argv): Argv => {
  const outputDefault = `${process.cwd()}/messages.json`
  return args
    .option('target', {
      type: 'string',
github kamikat / bilibili-get / lib / extractor.js View on Github external
var debug = require('debug').debug('bilibili:i:extractor');
var check = require('debug').debug('bilibili:d:extractor');
var playUrl = require('bilibili-playurl');
var request = null;

var setRequestOptions = function (options = {}) {
  options = Object.assign({
    gzip: true,
    resolveWithFullResponse: true,
  }, options);
  options.headers = Object.assign({
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'
  }, options.headers);
  request = require('request-promise-native').defaults(options);
};

setRequestOptions();
github kazupon / vue-i18n-locale-message / src / reflector.ts View on Github external
import { LocaleMessageMeta, SFCFileInfo } from '../types'
import { VueTemplateCompiler } from '@vue/component-compiler-utils/dist/types'

import { parse } from '@vue/component-compiler-utils'
import * as compiler from 'vue-template-compiler'
import path from 'path'

import { debug as Debug } from 'debug'
const debug = Debug('vue-i18n-locale-message:reflector')

export default function reflectLocaleMessageMeta (basePath: string, components: SFCFileInfo[]): LocaleMessageMeta[] {
  return components.map(target => {
    const desc = parse({
      source: target.content,
      filename: target.path,
      compiler: compiler as VueTemplateCompiler
    })
    const { contentPath, component, messageHierarchy } = parsePath(basePath, target.path)
    const cm = ''
    return {
      contentPath,
      content: cm,
      blocks: desc.customBlocks,
      component,
      messageHierarchy