@drone1/alt
Version:
An AI-powered localization tool
36 lines (32 loc) • 763 B
JavaScript
export function createLog(isDevMode) {
return {
// T/D/V blackholed until program options are parsed
T: () => { },
D: () => { },
V: () => { },
E: function(args) {
console.error(isDevMode ? args : (args?.message ?? args))
},
W: function(...args) {
console.warn(...args)
},
I: function(...args) {
console.log(...args)
},
}
}
export function initLogFromOptions({ options, log }) {
// Init optional logging functions
log.V = (options.trace || options.debug || options.verbose) ? function(...args) {
console.log(...args)
} : () => {
}
log.D = (options.trace || options.debug) ? function(...args) {
console.debug(...args)
} : () => {
}
log.T = options.trace ? function(...args) {
console.debug(...args)
} : () => {
}
}