当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript debug类代码示例

本文整理汇总了TypeScript中debug的典型用法代码示例。如果您正苦于以下问题:TypeScript debug类的具体用法?TypeScript debug怎么用?TypeScript debug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了debug类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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


注:本文中的debug类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。