mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: more process.env references (#13106)
This commit is contained in:
parent
e5457ac8ee
commit
6c7d51da34
15 changed files with 62 additions and 28 deletions
|
|
@ -14,7 +14,6 @@ import {
|
|||
} from 'src/constants';
|
||||
import { OnEvent } from 'src/decorators';
|
||||
import { SystemConfigDto, SystemConfigTemplateStorageOptionDto, mapConfig } from 'src/dtos/system-config.dto';
|
||||
import { LogLevel } from 'src/enum';
|
||||
import { IConfigRepository } from 'src/interfaces/config.interface';
|
||||
import { ArgOf, IEventRepository } from 'src/interfaces/event.interface';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
|
|
@ -52,7 +51,7 @@ export class SystemConfigService extends BaseService {
|
|||
|
||||
@OnEvent({ name: 'config.update', server: true })
|
||||
onConfigUpdate({ newConfig: { logging } }: ArgOf<'config.update'>) {
|
||||
const envLevel = this.getEnvLogLevel();
|
||||
const { logLevel: envLevel } = this.configRepository.getEnv();
|
||||
const configLevel = logging.enabled ? logging.level : false;
|
||||
const level = envLevel ?? configLevel;
|
||||
this.logger.setLogLevel(level);
|
||||
|
|
@ -63,7 +62,8 @@ export class SystemConfigService extends BaseService {
|
|||
|
||||
@OnEvent({ name: 'config.validate' })
|
||||
onConfigValidate({ newConfig, oldConfig }: ArgOf<'config.validate'>) {
|
||||
if (!_.isEqual(instanceToPlain(newConfig.logging), oldConfig.logging) && this.getEnvLogLevel()) {
|
||||
const { logLevel } = this.configRepository.getEnv();
|
||||
if (!_.isEqual(instanceToPlain(newConfig.logging), oldConfig.logging) && logLevel) {
|
||||
throw new Error('Logging cannot be changed while the environment variable IMMICH_LOG_LEVEL is set.');
|
||||
}
|
||||
}
|
||||
|
|
@ -109,8 +109,4 @@ export class SystemConfigService extends BaseService {
|
|||
const { theme } = await this.getConfig({ withCache: false });
|
||||
return theme.customCss;
|
||||
}
|
||||
|
||||
private getEnvLogLevel() {
|
||||
return process.env.IMMICH_LOG_LEVEL as LogLevel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue