feat(web,server)!: runtime log level (#5672)
* feat: change log level at runtime * chore: open api * chore: prefer env over runtime * chore: remove default env value
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// TODO: remove nestjs references from domain
|
||||
import { LogLevel } from '@nestjs/common';
|
||||
import { LogLevel } from '@app/infra/entities';
|
||||
import { ConfigModuleOptions } from '@nestjs/config';
|
||||
import Joi from 'joi';
|
||||
|
||||
@@ -18,19 +18,11 @@ export const immichAppConfig: ConfigModuleOptions = {
|
||||
DB_PASSWORD: WHEN_DB_URL_SET,
|
||||
DB_DATABASE_NAME: WHEN_DB_URL_SET,
|
||||
DB_URL: Joi.string().optional(),
|
||||
LOG_LEVEL: Joi.string().optional().valid('simple', 'verbose', 'debug', 'log', 'warn', 'error').default('log'),
|
||||
LOG_LEVEL: Joi.string()
|
||||
.optional()
|
||||
.valid(...Object.values(LogLevel)),
|
||||
MACHINE_LEARNING_PORT: Joi.number().optional(),
|
||||
MICROSERVICES_PORT: Joi.number().optional(),
|
||||
SERVER_PORT: Joi.number().optional(),
|
||||
}),
|
||||
};
|
||||
|
||||
export function getLogLevels() {
|
||||
const LOG_LEVELS: LogLevel[] = ['verbose', 'debug', 'log', 'warn', 'error'];
|
||||
let logLevel = process.env.LOG_LEVEL || 'log';
|
||||
if (logLevel === 'simple') {
|
||||
logLevel = 'log';
|
||||
}
|
||||
const logLevelIndex = LOG_LEVELS.indexOf(logLevel as LogLevel);
|
||||
return logLevelIndex === -1 ? [] : LOG_LEVELS.slice(logLevelIndex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user