mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-03-11 01:27:30 +01:00
chore: improve logging
This commit is contained in:
parent
e092ece430
commit
aad9c79391
3 changed files with 10 additions and 2 deletions
1
.env
1
.env
|
@ -10,6 +10,7 @@
|
|||
# Server Configs
|
||||
# -----------
|
||||
# LOG_LEVEL='info'
|
||||
# LOG_JSON=true
|
||||
# TOR_PROXY_SERVER=socks://127.0.0.1:9050
|
||||
# DISABLE_TWOFA=true
|
||||
|
||||
|
|
|
@ -11,11 +11,13 @@ import { ApiModule } from './modules/api/api.module';
|
|||
import { getAuthToken } from './utils/request';
|
||||
import { FetchModule } from './modules/fetch/fetch.module';
|
||||
import { appConstants } from './utils/appConstants';
|
||||
import { transports, format } from 'winston';
|
||||
import configuration from './config/configuration';
|
||||
import winston from 'winston';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import cookie from 'cookie';
|
||||
|
||||
const { combine, timestamp, prettyPrint, json } = format;
|
||||
|
||||
export type ContextType = {
|
||||
req: any;
|
||||
res: any;
|
||||
|
@ -95,7 +97,10 @@ export type JwtObjectType = {
|
|||
inject: [ConfigService],
|
||||
useFactory: (config: ConfigService) => ({
|
||||
level: config.get('logLevel'),
|
||||
transports: [new winston.transports.Console()],
|
||||
transports: [new transports.Console()],
|
||||
format: config.get('logJson')
|
||||
? combine(timestamp(), json())
|
||||
: combine(timestamp(), prettyPrint()),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
|
|
|
@ -26,6 +26,7 @@ export type YamlEnvs = {
|
|||
type ConfigType = {
|
||||
basePath: string;
|
||||
isProduction: boolean;
|
||||
logJson: boolean;
|
||||
playground: boolean;
|
||||
logLevel: string;
|
||||
jwtSecret: string;
|
||||
|
@ -76,6 +77,7 @@ export default (): ConfigType => {
|
|||
|
||||
const config: ConfigType = {
|
||||
isProduction,
|
||||
logJson: process.env.LOG_JSON === 'true',
|
||||
masterPasswordOverride: process.env.MASTER_PASSWORD_OVERRIDE || '',
|
||||
disable2FA: process.env.DISABLE_TWOFA === 'true',
|
||||
basePath: process.env.BASE_PATH || '',
|
||||
|
|
Loading…
Add table
Reference in a new issue