Skip to content

Commit

Permalink
fix: logger & build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lellansin authored and czy88840616 committed Nov 15, 2018
1 parent 47f46c3 commit c2e29aa
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
9 changes: 9 additions & 0 deletions packages/midway-schedule/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
app.js
app.d.ts
app.js.map
agent.js
agent.d.ts
agent.js.map
lib/*.js
lib/*.d.ts
lib/*.js.map
10 changes: 1 addition & 9 deletions packages/midway-schedule/agent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
const wrapped = require('egg-schedule/agent');

module.exports = (agent) => {
if (!agent.loggers.scheduleLogger) {
agent.loggers.scheduleLogger = console;
agent.loggers.scheduleLogger.unredirect = () => {};
}
wrapped(agent);
};
module.exports = require('egg-schedule/agent');
2 changes: 1 addition & 1 deletion packages/midway-schedule/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const loadEggSchedule = require('egg-schedule/lib/load_schedule');

module.exports = (app) => {
// don't redirect scheduleLogger
// app.loggers.scheduleLogger.unredirect('error');
app.loggers.scheduleLogger.unredirect('error');

// 'app/schedule' load egg-schedule (spec for egg-logxx rotate)
const schedules = loadEggSchedule(app);
Expand Down
21 changes: 21 additions & 0 deletions packages/midway-schedule/config/config.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const path = require('path');

module.exports = (appInfo) => {
const config = {};

config.customLogger = {
scheduleLogger: {
consoleLevel: 'NONE',
file: path.join(
appInfo.root,
'logs',
appInfo.name,
'midway-schedule.log',
),
},
};

return config;
};
1 change: 1 addition & 0 deletions packages/midway-schedule/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "schedule"
},
"scripts": {
"build": "npm run lint && midway-bin build -c",
"lint": "../../node_modules/.bin/tslint --format prose -c ../../tslint.json src/**/*.ts test/**/*.ts",
"test": "npm run lint && midway-bin clean && NODE_ENV=test midway-bin test --ts"
},
Expand Down
1 change: 0 additions & 1 deletion packages/midway-schedule/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"stripInternal": true,
"pretty": true,
"declaration": true,
"outDir": "dist",
"lib": ["es2017", "dom"],
"sourceMap": true
},
Expand Down

0 comments on commit c2e29aa

Please sign in to comment.