Lookman: The Debugger You'll Actually Enjoy Using
Logging shouldn't feel like a chore. We’ve all been there: peppering our code with console.log("here1"), console.log("data", data), and then spending twenty minutes trying to find where that specific log is coming from in the source code.
Lookman is a lightweight, breakpoint-free JavaScript debugging utility designed to give you superpowers without the overhead of a heavy library.
Why not just use console.log?
Because Lookman does the heavy lifting for you:
📍 Automatic Source Mapping: It tells you exactly which file and line the log came from.
🔄 State Monitoring: It detects if a value changed since the last time that line ran.
⏳ Async First: Pass it a Promise, and it logs the pending, resolved, and rejected states automatically.
🚀 Installation
No npm install fatigue here. Just grab the file and go.
Bash
Copy lookman.js into your project
cp lookman.js src/utils/lookman.js
🔥 Quick Start
JavaScript
import { dbg } from './lookman.js';
const user = { name: 'Alice', age: 30 };
dbg(user, 'user');
// Output: [src/app.js:12] user [object] { name: 'Alice', age: 30 }
The best part? dbg() returns the value, so you can wrap expressions without breaking your flow:
JavaScript
const result = dbg(calculateComplexMath(), 'math-check');
✨ Power Features
- Reactive Watching (dbg.watch) Stop wondering when a property gets mutated. Wrap an object in a Proxy and see every change in real-time.
JavaScript
const state = dbg.watch({ count: 0 }, 'state');
state.count = 1;
// ⚡ WATCH [app.js:5] state.count -> 1 (was: 0)
- Intelligent Promises Don't write .then(res => console.log(res)). Just wrap the fetch.
JavaScript
const data = await dbg(fetchUser(id), 'UserFetch');
// ⏳ pending...
// ✅ resolved (+88ms) { id: 1, name: 'Alice' }
- Change Detection In a loop or a React render? dbg.silent() only barks when the value actually changes, saving your console from being flooded.
Top comments (0)