Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayushkavad/console-enhance
Enhanced console.log with variable names, types, and memory tracking.
https://github.com/ayushkavad/console-enhance
debugging developer-tools javascript logging nodejs npm typescript
Last synced: 10 days ago
JSON representation
Enhanced console.log with variable names, types, and memory tracking.
- Host: GitHub
- URL: https://github.com/ayushkavad/console-enhance
- Owner: ayushkavad
- Created: 2024-11-22T19:18:40.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-11-22T19:39:31.000Z (about 1 month ago)
- Last Synced: 2024-11-22T20:25:12.247Z (about 1 month ago)
- Topics: debugging, developer-tools, javascript, logging, nodejs, npm, typescript
- Language: TypeScript
- Homepage:
- Size: 9.41 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# console-enhance
🚀 A powerful console logging enhancement library for Node.js applications that adds colors, timestamps, and advanced debugging features.
## 📋 Features
- 🎨 Rich colored output for better visibility
- ⏰ Customizable timestamp formats
- 📊 Real-time memory usage monitoring
- ⏱️ High-precision performance timing
- 🔍 Detailed stack trace support
- ⚙️ Flexible configuration options
- 🌈 Multiple log levels with visual distinction
- 🔄 Async operation support## 🚀 Installation
```bash
npm install console-enhance
# or
yarn add console-enhance
# or
pnpm add console-enhance
```## 🎯 Quick Start
```typescript
import { log } from "console-enhance";// Basic logging
log("Hello, World!");
// Output: [2024-03-21 10:30:45] Hello, World!
```### ⏱️ Performance Timing
```typescript
// Measure operation duration
log.time("database-query");
await fetchDataFromDB();
log.timeEnd("database-query");
// Output: [10:30:45] database-query: 123ms
```### 💾 Memory Monitoring
```typescript
// Track memory usage
log.memory();
//Output: Memory impact: 0MB
```### 🔍 Debug with Stack Traces
```typescript
// Get detailed error information
log.trace("Authentication failed");
// Output: [10:30:45] Authentication failed
// at AuthService.validate (/src/auth.ts:45:5)
// at Router.authenticate (/src/routes.ts:12:3)
```### ⚙️ Configuration
```typescript
log.configure({
showTimestamp: true,
dateFormat: "YYYY-MM-DD HH:mm:ss",
colors: true,
logLevel: "info",
prefix: "MyApp",
outputFile: "app.log", // Optional file logging
});
```## 📖 API Reference
### Log Levels
| Method | Description | Use Case |
| -------------- | ---------------- | ----------------------- |
| `log(message)` | Standard logging | General purpose logging |### Utility Methods
| Method | Description |
| -------------------- | --------------------------- |
| `log.time(label)` | Start a performance timer |
| `log.timeEnd(label)` | End timer and show duration |
| `log.memory()` | Show memory statistics |
| `log.trace(message)` | Log with stack trace |
| `log.clear()` | Clear console output |### Configuration Options
```typescript
interface LogOptions {
showTimestamp?: boolean; // Show/hide timestamps
dateFormat?: string; // Moment.js format string
colors?: boolean; // Enable/disable colors
logLevel?: "debug" | "info" | "warn" | "error"; // Minimum log level
prefix?: string; // Add prefix to all logs
outputFile?: string; // File to write logs to
maxFileSize?: number; // Max log file size in MB
compress?: boolean; // Compress old log files
}
```## 🤝 Contributing
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) for details.
## 📄 License
MIT