open-index/open-npm huggingface dataset:
npm package: @geren32/logger
Description: High-performance logger with context and masking
Latest version: 1.0.1

# @denis_softdoes/logger

Structured `pino` logger with request-scoped context propagation, recursive masking and optional rotating file output.

## Features

- JSON logs to `stdout` by default
- Optional rotating file logs
- `AsyncLocalStorage` helpers for `requestId`, `traceId`, `userId`, `tenantId`
- Recursive masking with circular reference protection
- Safe `Error` serialization
- TypeScript-first API

## Install

```bash
npm install @denis_softdoes/logger
```

## Basic Usage

```ts
import { createLogger } from '@denis_softdoes/logger';

const logger = createLogger('billing-service');

logger.info('Invoice created', {
  invoiceId: 42,
  customerEmail: 'team@example.com',
});
```

## Request Context

```ts
import { createLogger, runWithLogContext } from '@denis_softdoes/logger';

const logger = createLogger('api');

runWithLogContext({ requestId: 'REQ-1', traceId: 'TRACE-1' }, () => {
  logger.info('Request started');
});
```

## NestJS Integration

```ts
import {
  createLogger,
  createNestLoggerService,
} from '@denis_softdoes/logger';

const logger = createLogger('api');
const nestLogger = createNestLoggerService(logger);

app.useLogger(nestLogger);
```

## Configuration

```ts
import { createLogger } from '@denis_softdoes/logger';

const logger = createLogger('api', {
  level: 'debug',
  masks: ['ssn'],
  console: { enabled: true },
  file: {
    enabled: true,
    dir: 'logs',
    fileName: 'app.log',
    errorFileName: 'error.log',
    maxSize: '10M',
    maxFiles: 7,
  },
});
```

Environment variables:

- `LOG_LEVEL`
- `LOG_TO_FILE`
- `LOG_DIR`
- `LOG_FILE_NAME`
- `LOG_ERROR_FILE_NAME`
- `LOG_FILE_MAX_SIZE`
- `LOG_FILE_MAX_FILES`

## Notes

- File logging is opt-in.
- Masked fields are matched case-insensitively.
- Arrays, nested objects and `Error` instances are handled safely.