本文整理匯總了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;
};
示例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}`);
});
示例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);
}
示例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);
}
示例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))
));
};
};
示例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);
};
}
};
示例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))
};
};
示例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'),
}
}
示例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`);
}
};
}
示例10: onListening
function onListening(): void {
const addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
Debug('Listening on ' + bind);
}