diff --git a/processor/src/log.ts b/processor/src/log.ts index f2a04763e0..7c9a126619 100644 --- a/processor/src/log.ts +++ b/processor/src/log.ts @@ -4,10 +4,28 @@ const logLevels: ReadonlyArray = ['debug', 'info', 'warn', 'error'] const level = logLevels.indexOf(LOG_LEVEL) +const getTimeString = () => { + const now = new Date() + const isoString = `[${now.toISOString().split('.')[0]}Z] ` + return isoString +} + /* eslint-disable no-console */ export const log = { - debug: level <= 0 ? console.debug : () => {}, - info: level <= 1 ? console.info : () => {}, - warn: level <= 2 ? console.warn : () => {}, - error: level <= 3 ? console.error : () => {}, + debug: + level <= 0 + ? (...args: Array) => console.debug(getTimeString(), ...args) + : () => {}, + info: + level <= 1 + ? (...args: Array) => console.info(getTimeString(), ...args) + : () => {}, + warn: + level <= 2 + ? (...args: Array) => console.warn(getTimeString(), ...args) + : () => {}, + error: + level <= 3 + ? (...args: Array) => console.error(getTimeString(), ...args) + : () => {}, }