# ReplLogger

**Kind:** Class

**Source:** [`packages/core/repl/repl-logger.ts`](https://github.com/nestjs/nest/blob/master/packages/core/repl/repl-logger.ts#L6)

**Part of:** [Core](subsystem-packages-core)

`ReplLogger` provides logging support for the REPL subsystem, centralizing how messages are emitted during interactive sessions. Its `log()` method should be used by REPL commands and runtime flows that need to report status, output, or diagnostic information consistently.

**Extends:** `ConsoleLogger`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `log` | `log(_message: any, context: string)` | `void` |

## Where it refuses work

- `ReplLogger` stops the work with an early return when `ReplLogger.ignoredContexts.includes(context!)`.

## Diagram

```mermaid
graph LR
  Command[REPL Command] --> Logger[ReplLogger]
  Runtime[REPL Runtime] --> Logger
  Logger --> Output[Interactive Console Output]
```

## Usage

```ts
import { ReplLogger } from "./repl-logger";

const logger = new ReplLogger();

logger.log("REPL session started");

// Use the shared logger from command handlers or runtime operations.
function runCommand(command: string) {
  logger.log(`Executing command: ${command}`);
}

runCommand("help");
```

## AI Coding Instructions

- Use `ReplLogger.log()` for REPL-facing messages instead of writing directly to the console.
- Keep logged messages concise and actionable because they are displayed in an interactive terminal context.
- Reuse the logger instance managed by the REPL runtime when one is available; avoid creating unnecessary per-command instances.
- Preserve existing output formatting and ordering so command output remains predictable for users and tests.

## How it works

## `ReplLogger`

`ReplLogger` is a `ConsoleLogger` subclass used when `repl()` creates a Nest application context. The REPL passes a new instance as the context’s `logger` option before initializing the application. [packages/core/repl/repl-logger.ts:6](packages/core/repl/repl-logger.ts#L6) [packages/core/repl/repl.ts:16-20](packages/core/repl/repl.ts#L16-L20)

It overrides only `log`; inherited methods such as `error`, `warn`, `debug`, `verbose`, and `fatal` are not overridden. [packages/core/repl/repl-logger.ts:13-19](packages/core/repl/repl-logger.ts#L13-L19) [packages/common/services/console-logger.service.ts:192-276](packages/common/services/console-logger.service.ts#L192-L276)

## Relationships

- IMPORTS → `ConsoleLogger`
