console.mog
v0.0.59
Published
Looksmax your console π€«π§
Downloads
2,715
Readme
A powerful tool for building attractive logs that closely represent your data.
Welcome to console.mog, a transformative tool designed to take our beloved console
from mundane to magnificent. This library gives you the ability to create gorgeous terminal readouts without adopting the technical overhead that comes with a dedicated CLI-builder.
See Features | Get Started | Should I Use?
As simple as this...
import mog from 'console.mog'; // Also supports CJS
mog(console); // And you're done!
and now you have this...
[!WARNING]
This project is in alpha (πͺπΊ). It is not ready for production use and will not be for several more weeks/months.
Features π π»
π Transformative Logging Experience
- Looksmax your logs: Beautify your terminal output without breaking a sweat.
- Every native logging feature remains, but each has been supercharged with added functionality and a brand new look.
- Minimal setup: A single function call is all it takes to supercharge your console, but the powerful API enables deep customization!
- Add colors, links, and rainbow text to your logs with ease.
π Simple Declarative API
- Works seamlessly with console.log, console.group, and other familiar methods.
- Infinite method chaining to build complex reports quickly.
- Fully typed, for your convenience.
- Polyfills / fallbacks available for any environment* you find wanting for style.
π Represent any data or process
- Implicit and explicit syntax highlighting for structured data.
- Promise visualization: See how promises resolve or reject in real time, animations and all.
- Advanced tree and table rendering for nested or tabular data structures.
π― Style + Substance
- Built-in integrations to send your logs whereever they need to go, and a powerful API to build your own. Built in:
- Filesystem
- Discord Webhooks
- Generic Remote Server
- Generic Webhooks
[!IMPORTANT]
Full documentation available soon.
Pre-Launch Requirements
Stuff I gotta do before shilling on reddit. π€¨π
This project is in the first phase of development. Here's a list of milestones to hit before releae:
Critical for alpha πΊ
Graceful failure. Currently crash reports are printed overtop of the console... can we wrap them to handle graceful failures?
Make sure
console.mog
has parity withconsole.log
- may need to just proxy stuff like chart to underlying functionality.console.time
andconsole.profile
methods need hooks for the Timestamp system.- dir, dirxml - https://developer.mozilla.org/en-US/docs/Web/API/console/dir_static
console.assert
https://developer.mozilla.org/en-US/docs/Web/API/console#using_string_substitutionsconsole.count
Make native fallbacks for when this is run in the browser.
Make readme
NOTE: Many calculations should be done on a per-line basis, not a per-log basis - aggressive caching will be required.
It appears that something related to the line splitting doesn't re-calculate until a full re-render...
There needs to be another check for if a smart-render will take the rendered content outside the bounds of the screen. If so, it must dumb-render once to re-align content to the bottom.
Critical for literally anything useful
- Performance improvements. Obviously nowhere near as fast as native implementation, but there's tremendous room for performance improvements.
- Currently dumb render starts from the top and goes down. That's silliness.
- VSCode only renders 1,100-ish logs anyhow. Rendering only needs to be fancy for the last few thousand logs.
- When the program exits / crashes, a static version of logs should be spat into the console. Nothing fancy.
- Determine interoperability with other logging libraries.
- Determine interoperability with CLI tools that handle other stuff
- Make static mode for CI
- There should be a check to see if we're simply adding characters to the end of the DOM. If appending, just print the line like normal instead of dumb rendering.
Known bugs
- logs created by piping a stream to console.mog() aren't included when the console re-renders on resize. Subsequent messages will restore the output, though...
Future features
console.promise(promise)
syntax,console.promiseAll(promises)
syntax.Render boxes, links, rainbow text.
terminal.link()
- https://www.npmjs.com/package/terminal-link
Create Toolbox interface that contains chalk, link, etc. and can be passed to every log.
Create Context interface that contains LogData, selected DOM information, etc.
Alignment api. Left, center, right align. Unsure how I'm going to do this.
console.center(console.log())
possible?SideEffect
class +sideEffects
config option, that will do other stuff with your logs when they occur. Builtins:FileSystem
will dump your logs in a file, nuff said.Discord
will turn your logs into a discord webhook.SimpleRemote
simple api for duplicating your logs as HTTP requestsSimpleWebhook
is this redundant with above?
console.tree()
for directly rendering nested structures. May need a callback fn to run on every node to getchildren
andlabel
.Syntax highlighting in returned info - https://www.npmjs.com/package/cli-highlight
Can be explicit
console.highlight("json", fs.readFileSync('./package.json'))
- Or implicit
console.log({keyOne: "string", keyTwo: 5, keyThree: [1,2,3]})
- Or implicit
console.directory()
?? - https://github.com/athityakumar/colorls#readmeconsole.styledTable()
more control over neat looking console.console.hr should accept a string that can be centered.
console.format
ortoolkit
or whatever should have acolorRange
function, that takes values and maps them to colors, like excel. This would be cool for number readouts.
Code cleanup
- LogData should be generic - I need to simplify the Log types and how they actually resolve their data.