Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peteringram0/babel-plugin-console-source
Add the file name and line numbers to all console logs.
https://github.com/peteringram0/babel-plugin-console-source
babel babel-plugin console-log line-numbers logging
Last synced: 3 months ago
JSON representation
Add the file name and line numbers to all console logs.
- Host: GitHub
- URL: https://github.com/peteringram0/babel-plugin-console-source
- Owner: peteringram0
- Created: 2018-07-18T16:24:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-31T13:10:54.000Z (about 4 years ago)
- Last Synced: 2024-10-17T11:53:48.641Z (3 months ago)
- Topics: babel, babel-plugin, console-log, line-numbers, logging
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 37
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-babel - console-source - Prepends the file name and line numbers for all console commands (Plugins / General Plugins)
README
# Babel-plugin-console-source
Prepends file name and line numbers for each console command, based on the source files.````javascript
// app.js
class App() {
constructor() {
console.log('test')
}
}
↓ ↓ ↓ ↓ ↓ ↓
class App() {
constructor() {
console.log('app.js (3:8)', 'test')
}
}// test.js
class Test() {
constructor() {
console.log('test two')
}
}
↓ ↓ ↓ ↓ ↓ ↓
class Test() {
constructor() {
console.log('test.js (3:8)', 'test two')
}
}
````### Usage
````bash
$ yarn add babel-plugin-console-source -D
````.babelrc
````javascript
{
"plugins": [
// consoleSource // No options required
// You can pass in the following options
["console-source", {
"segments": 1, // NOT REQUIRED
// 0 = full file path (Default)
// 1 = file name ONLY
// 2 = file name and last segment
"splitSegment": '/' // How to split the path - NOT REQUIRED
// Default is / for Linux and OSX
// Windows users can use "\\" here if needed
}]
]
}
````### Notes
NPM Install: https://www.npmjs.com/package/babel-plugin-console-source