當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript debug.default方法代碼示例

本文整理匯總了TypeScript中debug.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript debug.default方法的具體用法?TypeScript debug.default怎麽用?TypeScript debug.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在debug的用法示例。


在下文中一共展示了debug.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: default

export default (namespace: string, emoji) => {
  const debug = _debug(namespace);
  return (...args: any[]) => {
    args.push('\n');
    debug(`\n  ${emoji}  %s`, ...args.map(
      arg =>  preetfy(String(arg))
    ));
  };
};
開發者ID:ArtemGovorov,項目名稱:reactjs-hackathon-kit,代碼行數:9,代碼來源:debug.ts

示例2: function

export default function (name?: string) {
  if (name) {
    const log = debug(`${pkg.name} (${name})`);
    log('ok')
    return function (formatter: any, ...argsarr: any[]) {
      const args = Array.prototype.slice.call(arguments);

      args[0] = `${new Date().toISOString()} - ${args[0]}`;

      log.apply(log, args);
    };
  } else {
    const log = debug(`${pkg.name}`);
    return function (formatter: any, ...argsarr: any[]) {
      const args = Array.prototype.slice.call(arguments);

      args[0] = `${new Date().toISOString()} - ${args[0]}`;

      log.apply(log, args);
    };
  }
};
開發者ID:evanshortiss,項目名稱:obd-parser,代碼行數:22,代碼來源:log.ts

示例3: function

export default function(module: string) {

  // set up logging
  const log = debug(module);

  if (!log.enabled) {
    // logging not enabled for this module, return do-nothing middleware
    return (context: any, next: () => void) => next();
  }

  /* istanbul ignore next */
  return async (context: any, next: () => void) => {

    const startTime = Date.now();
    const { method, url } = context.request;

    await next();

    const status = parseInt(context.status, 10);
    const requestBody = context.request.body === undefined ? undefined : JSON.stringify(context.request.body);
    const responseBody = context.body === undefined ? undefined : JSON.stringify(context.body);
    const time = Date.now() - startTime;

    if (requestBody !== undefined && responseBody !== undefined) {
      log(`${method} ${url} ${requestBody} -> ${status} ${responseBody} ${time}ms`);
    }

    if (requestBody !== undefined && responseBody === undefined) {
      log(`${method} ${url} ${requestBody} -> ${status} ${time}ms`);
    }

    if (requestBody === undefined && responseBody !== undefined) {
      log(`${method} ${url} -> ${status} ${responseBody} ${time}ms`);
    }

    if (requestBody === undefined && responseBody === undefined) {
      log(`${method} ${url} -> ${status} ${time}ms`);
    }
  };
}
開發者ID:carlansley,項目名稱:swagger2-koa,代碼行數:40,代碼來源:debug.ts

示例4: return

    return (target: any) => {
        const isValid = target.prototype.isValid;
        const debug = _debug(`demgel-mvc:model:${target.name}`);

        const newIsValid: Function = function () {
            debug('validating model...');
            const required: Array<string> = Reflect.getMetadata('required-property', target.prototype) || [];
            this.errors.clear();
            required.forEach(req => {
                if (!this[req]) {
                    this.errors.set(`required:${req}`, `${req} is required.`);
                }
            });
            debug(`found ${this.errors.size} required errors`);

            // tslint:disable-next-line:max-line-length
            const validationErrors: Map<string, string> = Reflect.getMetadata('validation-errors', target.prototype) || new Map<string, string>();
            debug(`found ${validationErrors.size} validation errors`);
            validationErrors.forEach((value, key) => {
                if (!this.errors.has(key)) {
                    debug('setting validation error');
                    this.errors.set(key, value);
                }
            });
            return isValid.apply(this);
        };

        target.prototype.isValid = newIsValid;

        return target;
    };
開發者ID:DemgelOpenSource,項目名稱:demgel-validation,代碼行數:31,代碼來源:model.ts

示例5: onListening

function onListening(): void {
  const addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  Debug('Listening on ' + bind);
}
開發者ID:yasupeke,項目名稱:niconico-desktop-server,代碼行數:7,代碼來源:www.ts

示例6: debug

 server.on("listening", () => {
   const addr = server.address();
   const bind =
     typeof addr === "string" ? `pipe ${addr}` : `port ${addr.port}`;
   debug(`Listening on ${bind}`);
   console.log(`Listening on ${bind}`);
 });
開發者ID:frankhale,項目名稱:toby,代碼行數:7,代碼來源:server.ts

示例7: onListening

 /**
  * Event listener for HTTP server "listening" event.
  */
 function onListening() {
     let addr = server.address();
     let bind = typeof addr === "string"
     ? "pipe " + addr
     : "port " + addr.port;
     let debugForExpress = debug("ExpressApplication");
     debugForExpress("Listening on " + bind);
 }
開發者ID:rajajhansi,項目名稱:aspnetcore-aurelia-tutorial,代碼行數:11,代碼來源:express-application.ts

示例8: onListening

  private onListening() {

    const debug = debugModule('express:server');
    if (_.isFunction(this.onListen)) this.onListen(this.port);
    let addr = this.server.address();
    let bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
    debug('Listening on ' + bind);

  }
開發者ID:thehachez,項目名稱:maduk,代碼行數:9,代碼來源:app.ts

示例9: Debug

export const Logger = (scope: string) => {
    const scopeDebug = Debug(scope);
    return {
        debug: (message: string, ...args: any[]) => {
            if (Environment.isProduction()) {
                logger.debug(format(scope, message), parse(args));
            }
            scopeDebug(message, parse(args));
        },
        verbose: (message: string, ...args: any[]) => logger.verbose(format(scope, message), parse(args)),
        silly: (message: string, ...args: any[]) => logger.silly(format(scope, message), parse(args)),
        info: (message: string, ...args: any[]) => logger.info(format(scope, message), parse(args)),
        warn: (message: string, ...args: any[]) => logger.warn(format(scope, message), parse(args)),
        error: (message: string, ...args: any[]) => logger.error(format(scope, message), parse(args))
    };
};
開發者ID:w3tecch,項目名稱:node-ts-boilerplate,代碼行數:16,代碼來源:Logger.ts

示例10: LoggerMock

export function LoggerMock(name: string): Ha4usLogger {
  const debug = Debug('ha4us:test:' + name)

  /* istanbul ignore next */
  function log(level: string) {
    return (...val: any[]) => {
      debug(level, ...val)
    }
  }

  return {
    silly: log('silly'),
    debug: log('debug'),
    info: log('info'),
    warn: log('warn'),
    error: log('error'),
  }
}
開發者ID:ha4us,項目名稱:ha4us.old,代碼行數:18,代碼來源:logger.mock.ts


注:本文中的debug.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。