diff --git a/README.md b/README.md index bfe83d5..9c5fb0e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ kdbから講義情報の取得と管理を行います。 | PG_DATABASE | Postgres接続先のデータベース名 | twinte_course_service | | PG_USER | Postgres接続に使用するユーザー名 | postgres | | PG_PASSWORD | Postgres接続に使用するパスワード | postgres | +| LOG_LEVEL | ログレベル fatal / error / warn / info / debug / trace / off | info | # 開発方法 Docker + VSCodeを推奨します。 diff --git a/package.json b/package.json index 768c3b0..331d3ae 100755 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "main": "index.js", "license": "MIT", "scripts": { - "dev": "ts-node ./src/index.ts", + "dev": "cross-env LOG_LEVEL=trace ts-node ./src/index.ts", "build": "tsc", "proto": "./proto-gen.sh", - "test": "jest --runInBand --coverage", + "test": "cross-env LOG_LEVEL=off jest --runInBand --coverage", "client": "grpcc --proto ./protos/CourseService.proto --address localhost:50051 -i", "lint": "eslint src/**/*.ts" }, @@ -36,6 +36,7 @@ }, "dependencies": { "@grpc/grpc-js": "^1.2.2", + "cross-env": "^7.0.3", "google-protobuf": "^3.14.0", "log4js": "^6.3.0", "pg": "^8.5.1", diff --git a/src/logger.ts b/src/logger.ts index d11b87d..556864a 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -2,7 +2,9 @@ import log4js from 'log4js' log4js.configure({ appenders: { std: { type: 'stdout' } }, - categories: { default: { appenders: ['std'], level: 'trace' } }, + categories: { + default: { appenders: ['std'], level: process.env.LOG_LEVEL ?? 'info' }, + }, }) export const logger = log4js.getLogger() diff --git a/yarn.lock b/yarn.lock index 7c2c26e..19d7b13 100755 --- a/yarn.lock +++ b/yarn.lock @@ -1535,6 +1535,13 @@ create-require@^1.1.0: resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + cross-spawn@^6.0.0: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -1546,7 +1553,7 @@ cross-spawn@^6.0.0: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2: +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==