34 lines
657 B
JavaScript
34 lines
657 B
JavaScript
/**
|
|
* simulationLogger.js
|
|
*
|
|
* Logger simples que imprime no console e acumula linhas para salvar em arquivo.
|
|
*/
|
|
|
|
const lines = []
|
|
|
|
function timestamp () {
|
|
return new Date().toISOString().replace('T', ' ').substring(0, 19)
|
|
}
|
|
|
|
export function logInfo (msg) {
|
|
const line = `[INFO] ${timestamp()} ${msg}`
|
|
console.log(line)
|
|
lines.push(line)
|
|
}
|
|
|
|
export function logWarning (msg) {
|
|
const line = `[WARN] ${timestamp()} ${msg}`
|
|
console.warn(line)
|
|
lines.push(line)
|
|
}
|
|
|
|
export function logError (msg) {
|
|
const line = `[ERROR] ${timestamp()} ${msg}`
|
|
console.error(line)
|
|
lines.push(line)
|
|
}
|
|
|
|
export function getLog () {
|
|
return lines.join('\n')
|
|
}
|