Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use nest app logger for Terminus per default #2552

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@


# [10.3.0-beta.0](https://github.com/nestjs/terminus/compare/10.2.3...10.3.0-beta.0) (2024-07-16)


### Features

* **typeorm:** change typeorm mongodb check ([2f0e97d](https://github.com/nestjs/terminus/commit/2f0e97d77c53826012bfe10ebd2ed111e0445cd4))
* Use nest app logger for Terminus per default ([40c6ec5](https://github.com/nestjs/terminus/commit/40c6ec5868c7838fe4344a563732d0f664cd55c6)), closes [#2547](https://github.com/nestjs/terminus/issues/2547)

## [10.2.3](https://github.com/nestjs/terminus/compare/10.2.2...10.2.3) (2024-02-18)


Expand Down
4 changes: 0 additions & 4 deletions lib/health-check/logger/default-logger.service.ts

This file was deleted.

31 changes: 20 additions & 11 deletions lib/health-check/logger/logger.provider.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
import { type LoggerService, type Provider, type Type } from '@nestjs/common';
import { DefaultTerminusLogger } from './default-logger.service';
import {
Logger,
type LoggerService,
type Provider,
type Type,
} from '@nestjs/common';

export const TERMINUS_LOGGER = 'TERMINUS_LOGGER';

const NOOP_LOGGER = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
log: () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
error: () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
warn: () => {},
};

export function getLoggerProvider(
logger?: Type<LoggerService> | boolean,
): Provider<LoggerService> {
// Enable logging
if (logger === true || logger === undefined) {
return {
provide: TERMINUS_LOGGER,
useClass: DefaultTerminusLogger,
useClass: Logger,
};
}

// Disable logging
if (logger === false) {
return {
provide: TERMINUS_LOGGER,
useValue: {
// eslint-disable-next-line @typescript-eslint/no-empty-function
log: () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
error: () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
warn: () => {},
},
useValue: NOOP_LOGGER,
};
}

// Custom logger
return {
provide: TERMINUS_LOGGER,
useClass: logger,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/terminus",
"version": "10.2.3",
"version": "10.3.0-beta.0",
"description": "Terminus integration provides readiness/liveness health checks for NestJS.",
"repository": {
"type": "git",
Expand Down
Loading