npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nest-elastic-logger

v2.1.1

Published

Customized logging solution, powered by Winston, adopts the Elasticsearch format for easy parsing of log entries.

Downloads

7

Readme

Introducing nest-elastic-logger, a logging library developed to reformat default Nest logger logs and generate rotating log files for integration with log shippers (like Filebeat).

Designed to enhance logging capabilities for improved readability and efficient log management.

Useful for:

  • Easier log readably
  • Log shippers ( Tested on Filebeat )
  • Monitoring logs

Features

  • Comes with Elasticsearch and JSON format out of the box
  • Automatic rotation of Log files
  • Custom print format

Installation:

npm i elastic-nest-logger

Setup

main.ts

export const bootstrap = async () => {
  const app = await NestFactory.create(AppModule);
  const customLogger = app.get(BetterLoggerService);

  app.useLogger(customLogger); // Use as global logger
  await app.listen(3000);
};

app.module.ts

import { Module } from '@nestjs/common';
import { BetterLoggerModule } from 'nest-elastic-logger';
import { AppController } from './app.controller';

@Module({
  imports: [BetterLoggerModule.forRoot({ serviceName: 'ServiceName', serviceVersion: '1.0.0' })],
  providers: [],
  controllers: [AppController],
})
export class AppModule {}

Usage

app.controller.ts

import { Controller, OnModuleInit } from '@nestjs/common';
import { BetterLoggerService } from 'nest-elastic-logger';

@Controller()
export class AppController implements OnModuleInit {
  private logger: BetterLoggerService = new BetterLoggerService('AppController'); // AppContoller context

  onModuleInit() {
    this.logger.log(
      'Hello There', // Message
      'onModuleInit', // Function Name
      { counter: 5, test: 'Hi' }, // Optional Args
      'extra data', // Optional Args // Optional Args
      'another extra data', // Optional Args
      { device: 'Cool Device' }, // Optional Args
    );
  }
}

output

[WhatupBackend v1.0.0] [15-11-2023 05:03:17] - [AppController] - [onModuleInit] - INFO - Hello There
Addional Details:
counter: 5
test: Hi
misc: extra data,another extra data
device: Cool Device

BetterLoggerSettings Type

| Property | Type | | ------------------- | -------------------------- | | serviceName | string | | serviceVersion | string | | removeNewlineFormat | boolean | | printFormat | winston.Logform.Format | | dailyRotateOptions | LimitedDailyRoatateOptions |

LimitedDailyRoatateOptions Type

| Property | Type | | -------- | ------ | | maxSize | string | | maxFiles | string |

Available Functions (BetterLoggerService)

| Function | Type | Log Level | | -------- | ------ | --------- | | log | string | INFO | | warn | string | WARN | | error | string | ERROR | | debug | string | DEBUG |