Skip to content

Commit

Permalink
chore: overwrite the default console.error in logQueryError (#33)
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 authored Dec 19, 2023
1 parent b8b7f5d commit b87701f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v1
Expand Down
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 b87701f

Please sign in to comment.