mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -05:00
Add config option for Disabling timestamp in log
Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
parent
c368434387
commit
44a7bfdd9c
3 changed files with 14 additions and 7 deletions
|
@ -20,6 +20,7 @@ export interface AppConfig {
|
|||
rendererBaseUrl: string;
|
||||
port: number;
|
||||
loglevel: Loglevel;
|
||||
showLogTimestamp: boolean;
|
||||
persistInterval: number;
|
||||
}
|
||||
|
||||
|
@ -59,6 +60,10 @@ const schema = Joi.object({
|
|||
.default(Loglevel.WARN)
|
||||
.optional()
|
||||
.label('HD_LOGLEVEL'),
|
||||
showLogTimestamp: Joi.boolean()
|
||||
.default(true)
|
||||
.optional()
|
||||
.label('HD_SHOW_LOG_TIMESTAMP'),
|
||||
persistInterval: Joi.number()
|
||||
.integer()
|
||||
.min(0)
|
||||
|
@ -79,6 +84,7 @@ export default registerAs('appConfig', () => {
|
|||
rendererBaseUrl: process.env.HD_RENDERER_BASE_URL,
|
||||
port: parseOptionalNumber(process.env.HD_BACKEND_PORT),
|
||||
loglevel: process.env.HD_LOGLEVEL,
|
||||
showLogTimestamp: process.env.HD_SHOW_LOG_TIMESTAMP,
|
||||
persistInterval: process.env.HD_PERSIST_INTERVAL,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ export function createDefaultMockAppConfig(): AppConfig {
|
|||
rendererBaseUrl: 'md-renderer.example.com',
|
||||
port: 3000,
|
||||
loglevel: Loglevel.ERROR,
|
||||
showLogTimestamp: true,
|
||||
persistInterval: 10,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -149,17 +149,17 @@ export class ConsoleLoggerService implements LoggerService {
|
|||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
};
|
||||
//TODO make timestamp optional (https://github.com/hedgedoc/hedgedoc/issues/5033)
|
||||
const timestamp = new Date(Date.now()).toLocaleString(
|
||||
undefined,
|
||||
localeStringOptions,
|
||||
);
|
||||
|
||||
let timeString = '';
|
||||
if (this.appConfig.showLogTimestamp) {
|
||||
timeString =
|
||||
new Date(Date.now()).toLocaleString(undefined, localeStringOptions) +
|
||||
' ';
|
||||
}
|
||||
const contextMessage = context ? blue(`[${context}] `) : '';
|
||||
const timestampDiff = this.updateAndGetTimestampDiff(isTimeDiffEnabled);
|
||||
|
||||
process.stdout.write(
|
||||
`${timestamp} ${contextMessage}${output}${timestampDiff}\n`,
|
||||
`${timeString}${contextMessage}${output}${timestampDiff}\n`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue