Skip to content

Commit

Permalink
chore: overwrite the default console.error in logQueryError
Browse files Browse the repository at this point in the history
make sure server disk does not get flooded with leoric logs by default
  • Loading branch information
cyjake committed Dec 19, 2023
1 parent b8b7f5d commit 8f96c52
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
11 changes: 11 additions & 0 deletions config/config.default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const debug = require('debug')('egg-orm');

exports.orm = {
client: 'mysql',
database: 'test',
Expand All @@ -15,6 +17,15 @@ exports.orm = {
underscored: true,
},

logger: {
logQuery(sql, duration, options) {
debug('[query] [%s] %s', duration, sql);
},
logQueryError(err, sql, duration, options) {
debug('[query] [%s] %s', duration, sql, err);
}
}

// or put your config into datasources array to connect multiple databases
// datasources: [],
};
3 changes: 2 additions & 1 deletion examples/typescript/basic/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"sourceMap": true
"sourceMap": true,
"skipLibCheck": true
},
"include": [
"types",
Expand Down
3 changes: 2 additions & 1 deletion examples/typescript/sequelize/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"sourceMap": true
"sourceMap": true,
"skipLibCheck": true
},
"include": [
"types",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
],
"license": "MIT",
"dependencies": {
"debug": "^4.3.4",
"leoric": "^2.9.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"sourceMap": true
"sourceMap": true,
"skipLibCheck": true
},
"include": [
"test/typescript",
Expand Down

0 comments on commit 8f96c52

Please sign in to comment.