Console logging library and Babel/Vite plugin that enhances logs by automatically injecting source filenames (relative to project root) and line numbers into log statements. Removes all logging in production environments.
- Print original (not transpiled) source filename and line number.
- Usable in React and React Native development.
- Completely remove logging in production.
dlog.log("message") // Prints to console.log
dlog.error("message") // Prints to console.errornpm install --save-dev @glitchybyte/dlogAdd plugin to babel.config.js
{
presets: [...],
plugins: [
...,
"@glitchybyte/dlog/babel"
]
}Add plugin to vite.config.ts
import dlog from "@glitchybyte/dlog/babel"
export default defineConfig({
plugins: [
react({
babel: {
plugins: [dlog]
}
})
]
})// path/to/my-code.ts
import { dlog } from "@glitchybyte/dlog"
dlog.log("Some message!")
// @path/to/my-code.ts:4 Some message!