I'm using loglevel
and loglevel-plugin-prefix
using the below code I'm able to get the date & time, logLevel, Message, loggerName.
Is there any way to get the function name or the line number with the fileName/path of the log?
import * as loglevel from 'loglevel'
import * as loglevelPluginPrefix from 'loglevel-plugin-prefix'
loglevelPluginPrefix.reg(loglevel)
loglevelPluginPrefix.apply(loglevel, {
format(level, name, timestamp) {
return `TIME: ${timestamp}, LOGGER: [${name}], LEVEL: ${level}, MESSAGE:`;
},
timestampFormatter(date) {
return date.toLocaleString()
},
levelFormatter(level) {
return level.toUpperCase()
},
nameFormatter(name) {
return name || 'global'
}
})
loglevel.info("Info from loglevel.js");
console output:
TIME: 10/13/2022, 2:02:46 PM, LOGGER: [global], LEVEL: INFO, MESSAGE: Info from loglevel.js
I want the function name and the filePath/name as well in the following output.