mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
Refactor logger
This commit is contained in:
@@ -9,7 +9,7 @@ export const LEVELS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const format = (level) => {
|
const format = (level) => {
|
||||||
const time = moment().format('HH:mm:ss (SSS)')
|
const time = moment().format('HH:mm:ss.SSS')
|
||||||
return `${time} : ${level} : `
|
return `${time} : ${level} : `
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +22,11 @@ export const Log = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const setLogLevel = function (level) {
|
export const setLogLevel = function (level) {
|
||||||
|
Log.debug = () => {}
|
||||||
|
Log.info = () => {}
|
||||||
|
Log.warn = () => {}
|
||||||
|
Log.error = () => {}
|
||||||
|
Log.fatal = () => {}
|
||||||
if (level <= LEVELS.fatal) {
|
if (level <= LEVELS.fatal) {
|
||||||
Log.fatal = console.log.bind(console, '\x1b[35m', format('FATAL'))
|
Log.fatal = console.log.bind(console, '\x1b[35m', format('FATAL'))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user