{"id":15594586,"url":"https://github.com/innei/nestjs-pretty-logger","last_synced_at":"2025-07-13T00:39:46.496Z","repository":{"id":209289614,"uuid":"723670161","full_name":"Innei/nestjs-pretty-logger","owner":"Innei","description":"🌟 Elevate NestJS logging with stylish, file-redirected, and real-time capable logging based on consola. Compact, powerful, and easy to integrate.","archived":false,"fork":false,"pushed_at":"2024-08-01T03:27:38.000Z","size":623,"stargazers_count":22,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T16:47:04.742Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Innei.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-26T12:14:06.000Z","updated_at":"2025-04-07T15:02:48.000Z","dependencies_parsed_at":"2024-02-06T13:37:43.436Z","dependency_job_id":"bdff475a-d645-4be0-a88a-d264699d48b6","html_url":"https://github.com/Innei/nestjs-pretty-logger","commit_stats":null,"previous_names":["innei/nestjs-pretty-logger"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Innei%2Fnestjs-pretty-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Innei%2Fnestjs-pretty-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Innei%2Fnestjs-pretty-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Innei%2Fnestjs-pretty-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Innei","download_url":"https://codeload.github.com/Innei/nestjs-pretty-logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251294762,"owners_count":21566333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T00:41:07.644Z","updated_at":"2025-04-28T10:29:31.432Z","avatar_url":"https://github.com/Innei.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Pretty Logger\n\n![1126201123](https://cdn.jsdelivr.net/gh/Innei/fancy-2023@main/2023/1126201123.png)\n\n## Introduction\n\n\"NestJS Pretty Logger\" is a versatile and visually appealing global Logger module for NestJS applications. This module extends the functionality of the default NestJS logger by utilizing the [consola](https://github.com/unjs/consola) library for enhanced aesthetics and includes features like file redirection and real-time logging capabilities.\n\n## Features\n\n- **Aesthetic and Functional Logging**: Integrates [consola](https://github.com/unjs/consola) for an enhanced logging experience.\n- **Log File Redirection**: Ability to redirect `stdout` to files, allowing for organized log management.\n- **App-Wide Logging Coverage**: Capable of covering the entire application's console and `stdout.write` functionalities.\n- **Real-Time Logging Support**: Provides the `onData()` hook for real-time logging implementations, such as custom log recorders or WebSocket real-time log streaming.\n\n## Installation\n\nTo install, run the following command:\n\n```bash\nnpm i @innei/pretty-logger-nestjs\n```\n\n## Usage\n\n### Basic Setup\n\nIn your `main.ts`:\n\n```typescript\n// main.ts\nimport { Logger } from '@innei/pretty-logger-nestjs'\n\nimport { NestFactory } from '@nestjs/core'\n\nimport { AppModule } from './app.module'\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule)\n  app.useLogger(app.get(Logger))\n  await app.listen(3000)\n}\nbootstrap()\n```\n\nIn your `app.module.ts`:\n\n```typescript\n// app.module.ts\nimport { LoggerModule } from '@innei/pretty-logger-nestjs'\n\nimport { Module } from '@nestjs/common'\n\nimport { AppController, AppService } from './app.controller'\n\n@Module({\n  imports: [LoggerModule],\n  controllers: [AppController],\n  providers: [AppService],\n})\nexport class AppModule {}\n```\n\n### Custom Logger Configuration\n\nConfigure and utilize advanced features:\n\n```typescript\n// Custom Logger Setup\nimport path from 'path'\nimport { createLogger, Logger } from '@innei/pretty-logger-nestjs'\n\nimport { NestFactory } from '@nestjs/core'\n\nimport { AppModule } from './app.module'\n\nconst customLogger = createLogger({\n  writeToFile: {\n    loggerDir: path.resolve(__dirname, './logs'),\n  },\n})\n\n// Wrap all console and stdout.write with customLogger\ncustomLogger.wrapAll()\n\n// Implement onData hook for real-time logging or custom actions\ncustomLogger.onData((data) =\u003e {\n  // Your custom implementation here\n})\n\n// Only error log\ncustomLogger.onStdErr((data) =\u003e {\n  // Your custom implementation here\n})\n\n// Only non-error log\ncustomLogger.onStdOut((data) =\u003e {\n  // Your custom implementation here\n})\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule)\n  Logger.setLoggerInstance(customLogger)\n  app.useLogger(app.get(Logger))\n  await app.listen(3000)\n}\nbootstrap()\n```\n\n**Note**: After invoking `wrapAll()`, avoid using `console.log` or similar stdout functions within `onData()` to prevent potential infinite loops.\n\n## Configuration Options\n\nThe `createLogger` method includes the `FileReporterConfig` interface for file redirection:\n\n```typescript\ninterface FileReporterConfig {\n  loggerDir: string // Required: Log file directory\n  stdoutFileFormat?: string // Optional: Default 'stdout_%d%.log'\n  stderrFileFormat?: string // Optional: Default 'error.log'\n  cron?: string // Optional: Default '0 0 * * *' for daily log rotation\n}\n```\n\nThis configuration is crucial for directing `stdout` to log files, with `loggerDir` being mandatory for specifying the log directory. The other parameters are optional, offering defaults for file formats and log rotation, which can be changed through the `cron` setting.\n\n## Contributions\n\nContributions to \"NestJS Pretty Logger\" are highly appreciated. Whether it's through pull requests or issue discussions, your feedback and contributions are valuable to the project.\n\n## License\n\n2024 © Innei, MIT License.\n\n\u003e [Personal Site](https://innei.in/) · GitHub [@Innei](https://github.com/innei/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnei%2Fnestjs-pretty-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnei%2Fnestjs-pretty-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnei%2Fnestjs-pretty-logger/lists"}