@temboplus/loggers
v0.1.0
Published
Loggers for TemboPlus applications and modules.
Downloads
93
Readme
temboplus-loggers
Loggers for TemboPlus applications and modules.
Requirements
- Node.js v22.19.0+ (LTS recommended)
- npm v10.9.3+
- TypeScript v5.9.3+
- tslib v2.8.1+, for optimized bundles
Installation
npm install --save @temboplus/loggersUsage
1. Import LoggersModule into the Root Module (AppModule):
import { Module } from '@nestjs/common';
import { LoggersModule } from '@temboplus/loggers';
@Module({
imports: [
LoggersModule.forRoot({ serviceName: '<serviceName>' }), // Import once here
// ... other modules
],
})
export class AppModule {}2. Sets custom logger service in NestJS Application instance:
import { LOGGERS_MODULE_ROOT_LOGGER } from '@temboplus/loggers';
// ...
const app = await NestFactory.create(AppModule, {
bufferLogs: true,
});
app.useLogger(app.get(LOGGERS_MODULE_ROOT_LOGGER));
// ...Use Nest built-in Logger in Services, Controllers etc.:
import { Injectable, Logger } from '@nestjs/common';
@Injectable()
export class ExampleService {
private readonly logger = new Logger(ExampleService.name);
someMethod(): void {
this.logger.debug('Some log message');
}
}4. OR; Inject LoggerService into Services, Controllers etc. using @InjectLogger:
import { Injectable } from '@nestjs/common';
import { InjectLogger, LoggerService } from '@temboplus/loggers';
@Injectable()
export class ExampleService {
constructor(@InjectLogger() private readonly logger: LoggerService) {
this.logger.setContext(ExampleService.name);
}
someMethod(): void {
this.logger.debug('Some log message');
}
}Contribute
We welcome contributions! Here's how to get started:
How to Contribute
Open an Issue Start by opening an issue to discuss your proposed changes.
Clone the Repo
git clone [email protected]:TemboPlus-Inc/temboplus-loggers.git cd temboplus-loggersInstall Dependencies
npm installCreate a Feature Branch
git checkout -b feature/<your-feature-name> mainMake Your Changes & Run Checks
npm run checkFor available scripts and automation workflows, see the Tasks guide.
Commit Your Changes
git commit -m "feat(<scope>): <add new feature description>"Push & Submit a Pull Request
git push origin feature/<your-feature-name>Then, open a Pull Request (PR) to the main branch.
Contribution Guidelines
- Follow SOLID principles to write clean, maintainable, and scalable code.
- Follow the GitFlow workflow branching model.
- Follow Conventional Commits (
feat,fix,chore, etc.). - Write meaningful commit messages, PR titles, and code comments.
- Ensure the code passes checks before submitting.
- Keep changes focused and well-scoped.
