NodeJS Console Object Debug Inspector
Or simply node-codein (longtail for SEO) is supposed to do what Webkit Inspector's Console does. Except this works exclusively with NodeJS.
Released under MIT License (included); some components have their own licenses but I kept all the comments in their headers so if you're a really really boring person (lawyer, attorney, prosecutor, whatever) you can check the files under libraries/.
Recommended: NodeJS v0.8.0+, Chrome 19.xx.xxxx.xx+
- Install the package via "npm install node-codein", then include it in your script with require("node-codein"); alternatively
- Download the package, put it somewhere you can find it
- In your script add require("path/to/folder/node-codein")
- Run nodejs
- Start %localappdata%/Google/Chrome/Application/chrome.exe --app=http://localhost:55281
- Make sure you only use Chrome. It might work on something else but going straight with Chrome will save you time.
- removed the buggy, CPU-clogging jsTree
- updated UI colors
- modified small real-estate features
- added progressive rendering
- exposed the whole module on global.nodecodein
- Displays objects in tree format, with expand/collapse controls
- Executes arbitrary code
- Wraps the common logging functions: console.log(), console.info(), console.warn() & console.error()
- Wraps unhandled exceptions via process.on('uncaughtException', ...)
- Broadcasts messages to all connected clients
- Reconnects automatically
Visible and hidden features
- Top buttons:
- enable iScroll (click-drag to scroll/pan)
- theme switcher (dark seems to attract the ladies lol :D)
- YAND.info (Node's API docs)
- Node's twitter
- Middle thin bar:
- drag to resize
- double click to hide input area
- Bottom row - left:
- hide/show input area
- clear all messages
- automatically expand objects (just first level)
- structure object levels + row highlighter
- input preservation (for spammers)
- Bottom row - right:
- expand + collapse every single visible object
- reload (alias for F5)
- duplicate window (opens all the messages in it; uses $.clone() so some controls might be inherited from the parent window)
- Not-so-obvious features:
- saves last 50 command in local storage, use arrow keys to navigate through previous commands
- typing suggestions and autocomplete
- shift+enter for new lines
- tab key indents
- Console log sometimes doesn't pass data (rarely... very... rarely). I planned on using EventSource but didn't stick to it because one end doesn't buffer the response and there's no flush command like in PHP. So what it does instead is it keeps connections in a waiting state and when it gets something, it writes the response, closing those connections. Then clients will automatically reconnect but in that split-second if there is any pre-connected client (as in managed to connect before any others), that client will get the logs and those who connected the millisecond later, won't get anything.
- Autocomplete spams your server. Lag is in place and can be tweaked but it'll basically chop-off words when you hit enter.
- iScroll + expand all + ctrl+f to find properties will lock the whole browser; not sure why, don't care much, just disable iScroll if you're using this tecnhique to find properties.
- Autocomplete may not appear after using left / right arrow keys or escape. This is intentional, because those 3 keys are GTFO master keys, but if you want the list of suggestions back, type some gibberish and press backspace.
- The whole source code is haywired or almost haywired.
- There's no syntax highlighting on the input. It will generate lags.
- Where are the variables from my own module? / How do I debug my module?
- What's wrong about the regular console?
Its overall buffer size, no syntax coloring, hard to use, no direct input, so forth. If you're familar to webkit's "Inspect Element" console tab, you'll see there are some differences.
- Then what's wrong with Eclipse's V8 Debugger?
A debugger is something totally different. Well not really but you still need to set breakpoints, stop executions, scope variables, etc. Plus you have to restart Node to put code in. I can make more excuses if necessary.
- Why not just fix node-inspector?
I tried. I first tried to pass back stringified objects and decode them in the local console. The problem was that there was a hardcoded limit of 80 characters beyond which the string turned into "str... (length: 2219)". I'm not sure where this came from but I believe it was built into v8 when it was compiled with Node. I also tried fixing scope:frame:handle problem but it seemed to pass back zeros no matter what.
- Can you help me do X / can you add X / can you fix X?
Open an issue here on GitHub, 3rd row, 4th button (or something like that), and let's have a look
Fork, pull, push, drag, chop, send, fax whatever you want you're free to do it.
Good luck buddy.