debug 模块(主要这个, 其他的已经官方够详细了)
- 安装和指定debug模块命名空间
- 在指定地方写debug语句, 支持Formatters
const mysql = require('./lib/mysql');
const debugPassportJyb = require('debug')('passportJyb')
module.exports = app => {
debugPassportJyb('debugPassportJyb doing some work %s', 'passportJybAuth' );
if (app.config.passportJyb.clients.mysqlOperate.app) mysql(app);
const index = app.config.coreMiddleware.length;
app.config.coreMiddleware.splice(index, 0, 'passportJybAuth');
};
复制代码
- node服务在调试时指定debug命名空间
"debug": "DEBUG=passport* egg-bin debug",
复制代码
支持正则: DEBUG=passport*
- 自定义格式
/**
* debug:自定义格式化
*/
var createDebug = require('debug')
createDebug.formatters.h = function(v) {
return v.toUpperCase();
};
var debug = createDebug('foo');
// 运行 DEBUG=foo node 04.js
// 输出 foo My name is CHYINGP +0ms
debug('My name is %h', 'chying');
复制代码
egg logger 日志模块
debug info warn err
使用 egg-bin 调试
- vscode 的 vscode-eggjs 插件 最近这个有个问题, 详细看我说明的另一个地址 this socket has been ended by other party