# @nestutils/logger

> Logging Module For NestJS

Latest version **0.0.3** (published 2024-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nestutils/logger
pnpm add @nestutils/logger
yarn add @nestutils/logger
bun add @nestutils/logger
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2024-02-17 |
| First published | 2022-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Priyanshu Belwal |
| Maintainers | belwalpb |
| Keywords | logger, nest-logger, javascript-logger |

## Links

- npm: https://www.npmjs.com/package/@nestutils/logger
- Repository: https://github.com/nestutils/logger
- Homepage: https://github.com/nestutils/logger#readme
- Issues: https://github.com/nestutils/logger/issues
- npm.io page: https://npm.io/package/@nestutils/logger

## Dependencies (1)

- [safe-stable-stringify](https://npm.io/package/safe-stable-stringify.md) ^2.4.3

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2024-02-17
- 0.0.2 — 2024-02-17
- 0.0.1-rc.11 — 2023-04-12
- 0.0.1-rc.10 — 2023-04-12
- 0.0.1-rc.9 — 2023-04-12
- 0.0.1-rc.8 — 2023-04-12
- 0.0.1-rc.7 — 2023-04-12
- 0.0.1-rc.6 — 2022-12-20
- 0.0.1-rc.5 — 2022-12-10
- 0.0.1-rc.4 — 2022-11-20
- 0.0.1-rc.3 — 2022-11-20
- 0.0.1-rc.2 — 2022-11-20
- 0.0.1-rc.1 — 2022-11-20

## README

<p align="center">
  <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>

<h1 align="center">@nestutils/logger</h1>

## Description
This NestJS Module works out of the box with NestJS Applications. Currently Providing Feature of transporting logs to console only.

## Installation
In your existing NestJS-based project:
```
$ npm install --save @nestutils/logger
```


## Usage
To configure global options with Logger, it can be registered at AppModule with global configuration options.
```typescript
import { Module } from '@nestjs/common'
import { LoggerModule } from '@nestutils/logger';
@Module({
    imports: [
    LoggerModule.forRoot({
      timestamp: true, // Whether to print timestamp with logs or not.
      defaultLoggingContext: 'DefaultContext', // Default Logging Context, in case if context is not provided, it will be used.
      providerName: 'DefaultProviderName' // Provider Name of current instance, which will be used for DI.
    }),
      ]
})
export class AppModule {}
```

To Use it in some specific portion of application
```typescript
import { Controller, Get, Query } from '@nestjs/common';
import { Logger } from '@nestutils/logger';

@Controller()
export class AppController {
  private readonly logger = new Logger({
    context: AppController.name
  })

  @Get()
  getHello(@Query('name') name: string) {
    this.logger.log('Request Received');
    // Request Received

    this.logger.log('Request Received For {}',name); 
    // Request Received For Joy
  }
}
```

To make this logger as default application logger, edit main.ts file similar below
```typescript
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { Logger } from '@nestutils/logger';

async function bootstrap() {
  const app = await NestFactory.create(AppModule,
     {
    logger: new Logger({
      context: 'NestApplication'
      timestamp: true // Optional Property, true by default.
    })
  }
  );
  await app.listen(3000);
}
bootstrap();
```

## Contributions
Any suggestions, issues, bug-fixes, PR's are most welcomed. Thanks.

## Note
This project is currently in active development 🚧. Breaking changes are expected.

---
_Source: https://npm.io/package/@nestutils/logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
