mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
fix: compatibility with log aggregators
This commit is contained in:
@@ -14,21 +14,15 @@
|
||||
*/
|
||||
import {LogLevel} from '../logger';
|
||||
import {Transformation} from '../transformation';
|
||||
import moment from 'moment';
|
||||
|
||||
/**
|
||||
* Transformation that adds a timestamp to output
|
||||
*/
|
||||
export class Timestamp implements Transformation {
|
||||
/**
|
||||
* Instantiate a new timestamp transformation
|
||||
*
|
||||
* @see https://momentjs.com/docs/#/displaying/format/
|
||||
* @param format Format for timestamps
|
||||
* Keep this transformation in production environments
|
||||
*/
|
||||
constructor(private readonly format = 'LLLL') {
|
||||
// noop
|
||||
}
|
||||
useInProduction = true;
|
||||
|
||||
/**
|
||||
* Add timestamp to output
|
||||
@@ -37,8 +31,6 @@ export class Timestamp implements Transformation {
|
||||
* @param output Output to add timestamp to
|
||||
*/
|
||||
transform(_logLevel: LogLevel, output: string): string {
|
||||
const now = moment();
|
||||
|
||||
return `[${now.format(this.format)}] ${output}`;
|
||||
return `[${new Date().toISOString()}] ${output}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user