Skip to content

Commit

Permalink
add: loglevel
Browse files Browse the repository at this point in the history
  • Loading branch information
SIY1121 committed Jan 26, 2021
1 parent f4cf337 commit d7b5a57
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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を推奨します。
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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==
Expand Down

0 comments on commit d7b5a57

Please sign in to comment.