tachybase_todo/packages/core/logger/src/config.ts
YANG QIA 318b433482
chore(logger): improve format (#3290)
* chore(logger): improve format

* fix: build

* feat: develop format

* chore: develop -> console
2023-12-30 23:34:40 +08:00

18 lines
755 B
TypeScript

import path from 'path';
export const getLoggerLevel = () =>
process.env.LOGGER_LEVEL || (process.env.APP_ENV === 'development' ? 'debug' : 'info');
export const getLoggerFilePath = (...paths: string[]): string => {
return path.resolve(process.env.LOGGER_BASE_PATH || path.resolve(process.cwd(), 'storage', 'logs'), ...paths);
};
export const getLoggerTransport = (): ('console' | 'file' | 'dailyRotateFile')[] =>
(
(process.env.LOGGER_TRANSPORT as any) ||
(process.env.APP_ENV === 'development' ? 'console' : 'console,dailyRotateFile')
).split(',');
export const getLoggerFormat = (): 'logfmt' | 'json' | 'delimiter' | 'console' =>
(process.env.LOGGER_FORMAT as any) || (process.env.APP_ENV === 'development' ? 'console' : 'json');