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