open-index/open-npm huggingface dataset:
npm package: @renkoya1/dev-log
Description: A simple development logging utility
Author: RenKoya1
Latest version: 0.0.4

# dev-log

A simple development logging utility that only logs in non-production environments.

## Installation

```bash
npm install @renkoya1/dev-log
```

## Usage

### Basic Usage

```typescript
import devLogger from "@renkoya1/dev-log";

// Direct function call
devLogger("Hello World!");

// Method calls
devLogger.log("Hello");
devLogger.debug("Debug message");
devLogger.info("Info message");
devLogger.warn("Warning message");
devLogger.error("Error message");
```

### Named Import

```typescript
import { devLogger } from "@renkoya1/dev-log";

devLogger.warn("Warning message");
devLogger.info("Info message");
```

## Features

- **Environment-aware**: Only logs when `NODE_ENV !== "production"` or `__DEV__` is true
- **Multiple log levels**: debug, info, warn, error
- **Direct function call**: `devLogger()` works the same as `devLogger.log()`
- **Timestamp logging**: `devLogger.time()`
- **Pretty printing**: `devLogger.pretty()` for formatted objects
- **Custom prefixes**: `devLogger.prefix("API")()` for categorized logs
- **Table display**: `devLogger.table()` for array/object visualization
- **Log grouping**: `devLogger.group()` for organized logs
- **Stack tracing**: `devLogger.trace()` for call stack
- **Performance measurement**: `devLogger.measure()` for timing functions
- **TypeScript support** included

## Advanced Examples

```typescript
import devLogger from "@renkoya1/dev-log";

// Timestamp logging
devLogger.time("User logged in at");

// Pretty print objects
devLogger.pretty({ user: { name: "John", age: 30 } });

// Custom prefix
const apiLogger = devLogger.prefix("API");
apiLogger("Request received");
apiLogger("Response sent");

// Table display
devLogger.table([
  { name: "John", age: 30 },
  { name: "Jane", age: 25 }
]);

// Log grouping
devLogger.group("User Authentication", () => {
  devLogger.info("Checking credentials");
  devLogger.info("Credentials valid");
});

// Performance measurement
await devLogger.measure("Database Query", async () => {
  // Your async operation here
  return await fetchData();
});

// Stack tracing
devLogger.trace("Debugging call stack");
```

## API Reference

### Core Methods
- `devLogger()` / `devLogger.log()` - General logging
- `devLogger.debug()` - Debug level logging
- `devLogger.info()` - Info level logging
- `devLogger.warn()` - Warning level logging
- `devLogger.error()` - Error level logging

### Utility Methods
- `devLogger.time()` - Log with ISO timestamp
- `devLogger.pretty()` - Pretty print objects with JSON formatting
- `devLogger.prefix(prefix)` - Create prefixed logger function
- `devLogger.table(data)` - Display data in table format
- `devLogger.group(label, fn)` - Group related logs
- `devLogger.trace()` - Log call stack
- `devLogger.measure(label, fn)` - Measure function execution time

## Environment Detection

The logger automatically detects development environment using:
1. `__DEV__` global variable (if defined)
2. `process.env.NODE_ENV !== "production"`

## License

MIT