osolog
v1.1.0
Published
It's just a console log extension
Readme
OsoLog 🐻
OsoLog is a lightweight, powerful extension for the JavaScript console.log. It transforms messy terminal outputs into structured, readable, and beautiful logs with zero effort.
Perfect for debugging complex objects, generating terminal tables, or preparing logs for external monitors like Splunk.
🚀 Key Features
- Structured Templates: Format objects into clean, scannable strings (Brackets & Keys).
- Auto-Tables: Render arrays and multidimensional data as beautiful CLI tables.
- Rich Coloring: Full integration with the
colorslibrary for vibrant terminal output. - Transformation Pipes: Pass data through custom functions before logging.
- TypeScript Support: Full type definitions included for a superior DX.
- NPM Safe: Fully backwards compatible with older versions.
📦 Installation
npm install osolog🛠 Quick Start
const OsoLog = require("osolog");
const log = new OsoLog();
// Log anything - Strings, Objects, Arrays, or Mixed!
log.R("Hello World", { status: "Active" }, [1, 2, 3]);💡 Advanced Usage
1. Object Templates (Brackets & Keys)
Templates are perfect for making objects readable at a glance or for structured logging systems.
const user = { id: 1, name: "Mario", role: "Admin" };
// Brackets Template: Clean and scannable
log.Template({ name: "brackets", title: "USER_AUTH", date: true }).R(user);
// Output: [USER_AUTH][2026-05-16T...][id:1][name:"Mario"][role:"Admin"]
// Keys Template: Valid JSON-like format
log.Template({ name: "keys", title: "API_RES", date: true }).R(user);
// Output: {"title":"API_RES","Date":"...","id":1,"name":"Mario","role":"Admin"}2. Beautiful Tables
Easily visualize arrays and multidimensional data.
const data = [
[1, "Node.js", "Stable"],
[2, "React", "Stable"]
];
// Multidimensional table with custom headers
log.Args({ head: ["ID", "Tech", "Status"] }).R(data);3. Custom Coloring
Apply vibrant styles to your logs using the built-in color engine.
log.Args({
colors: { key: ["green", "bold"], value: ["yellow"] },
template: { name: "brackets", title: "DEBUG" }
}).R({ database: "Connected", latency: "14ms" });
// Or apply a quick rainbow effect to a string
log.Args({ colors: ["rainbow", "bold"] }).R("Everything is awesome!");4. Transformation Functions (.Funcs)
Process your data on the fly before it hits the console.
const sum = (arr) => arr.reduce((a, b) => a + b, 0);
log.Funcs(sum).R([10, 20, 30]); // Output: 60⚙️ Configuration
You can initialize OsoLog with a global configuration object:
| Attribute | Default | Description |
| :--- | :--- | :--- |
| logger | true | Enable or disable all console output. |
| enableColors | false | Global toggle for terminal colors. |
| string_caps | false | Automatically convert all logged strings to UPPERCASE. |
| array | "default" | Set to "default_table" for automatic console.table. |
| multiarray | "default" | Set to "custom_table" for advanced CLI tables. |
⌨️ TypeScript Support
OsoLog comes with built-in type definitions. Enjoy full autocompletion in VS Code:
import OsoLog, { ConfigObject } from 'osolog';
const config: ConfigObject = { enableColors: true };
const log = new OsoLog(config);🔄 Backwards Compatibility
We care about your existing code. Version 1.1.0+ remains fully compatible with:
- The legacy
new osolog.R()constructor pattern. - Older configuration typos (e.g.,
multiarray: "defualt_table"). - Older template names (e.g.,
name: "brakets").
📜 License
MIT © Guillermo Salazar
