npm package: @lashdlhaldsfhoq/simpler
Description: A simple utility to unset console.log arguments and provide enhanced logging capabilities
Author: Your Name
Latest version: 2.0.1

# Simpler

A powerful utility library for managing console.log behavior and creating enhanced loggers with TypeScript support.

## Features

- **Console Control**: Easily unset and restore console.log functionality
- **Enhanced Loggers**: Create loggers with timestamps, colors, prefixes, and log levels
- **Log Buffering**: Buffer logs and flush them when needed
- **Performance Timing**: Measure and log execution times
- **Conditional Logging**: Log based on conditions or environment
- **Group & Table Support**: Use console.group and console.table with enhanced features
- **TypeScript Support**: Full TypeScript types included

## Installation

```bash
npm install simpler
```

## Usage

### Basic Console Control

```javascript
import { unsetConsoleLog, restoreConsoleLog, simpler } from 'simpler';

// Disable console.log
unsetConsoleLog();
console.log('This will not appear');

// Restore console.log
restoreConsoleLog();
console.log('This will appear');

// Quick disable using simpler()
simpler();
```

### Create Enhanced Loggers

```javascript
import { createLogger } from 'simpler';

// Create a logger with custom options
const logger = createLogger({
  timestamp: true,
  prefix: 'MyApp',
  color: true,
  minLevel: 'info' // Only log info and above
});

logger.debug('Debug message'); // Won't show (below minLevel)
logger.info('Info message');   // Will show with timestamp and prefix
logger.error('Error message'); // Will show in red

// Use advanced features
logger.group('Processing');
logger.time('operation');
// ... do something
logger.timeEnd('operation');
logger.groupEnd();

// Display data in table format
logger.table([
  { name: 'John', age: 30 },
  { name: 'Jane', age: 25 }
]);
```

### Log Buffering

```javascript
import { createBufferedLogger } from 'simpler';

const logger = createBufferedLogger({ prefix: 'Buffer' });

// Logs are stored, not printed
logger.log('First message');
logger.error('Error occurred');
logger.info('Info message');

// Flush all logs at once
logger.buffer.flush();

// Clear buffer without flushing
logger.buffer.clear();

// Get buffer entries
const entries = logger.buffer.getEntries();
```

### Conditional and Environment Logging

```javascript
import { conditionalLog, devLog } from 'simpler';

// Log only when condition is true
const debugMode = true;
conditionalLog(debugMode, 'Debug information');

// Log only in development environment
devLog('This only appears when NODE_ENV=development');
```

### Utility Functions

```javascript
import { prefixLog, jsonLog, measureTime, unsetAllConsole, restoreAllConsole } from 'simpler';

// Log with prefix
prefixLog('SERVER', 'Request received');

// Pretty print JSON
const data = { users: [{ name: 'John', age: 30 }] };
jsonLog(data, 4); // 4 spaces indentation

// Measure execution time
const result = await measureTime(async () => {
  await someAsyncOperation();
  return 'done';
}, 'Operation');
// Logs: "Operation: 123.45ms"

// Disable/restore all console methods
unsetAllConsole();  // Disables log, info, warn, error, debug
restoreAllConsole(); // Restores all methods
```

## API Reference

### Console Control

- `unsetConsoleLog()` - Disables console.log
- `restoreConsoleLog()` - Restores console.log
- `unsetAllConsole()` - Disables all console methods
- `restoreAllConsole()` - Restores all console methods
- `simpler()` - Quick function to unset console.log

### Logger Creation

- `createLogger(options)` - Creates an enhanced logger
- `createSilentLogger(options)` - Creates a logger and unsets console.log
- `createBufferedLogger(options)` - Creates a buffered logger

### Logger Options

```typescript
interface LogOptions {
  timestamp?: boolean;    // Add timestamps to logs
  prefix?: string;       // Add prefix to all logs
  color?: boolean;       // Use colors in output
  minLevel?: 'debug' | 'log' | 'info' | 'warn' | 'error'; // Minimum log level
}
```

### Utility Functions

- `conditionalLog(condition, ...args)` - Log when condition is true
- `devLog(...args)` - Log only in development
- `prefixLog(prefix, ...args)` - Log with a prefix
- `jsonLog(data, indent?)` - Pretty print JSON
- `measureTime(fn, label?)` - Measure function execution time

## License

MIT