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

@kittgen/nestjs-fluent-logger

v1.0.1

Published

Key Value Logger with fluent API and support for Redaction

Downloads

21

Readme

Kittgen Nestjs Key Value FluentLogger

Key Value Logger with support for redaction

Check the main page for Kittgen for further information.

Usage

Installation

npm i @kittgen/nestjs-fluent-logger

Using Fluent Key Value API

Example usage of logger

Log Example

import { FluentLogger } from '@kittgen/nestjs-fluent-logger';

class EmailService {
  constructor() {
    const logger = new FluentLogger(EmailService.name)
  }
  // ...
  logger.fluent()
        .add('send', 'email')
        .add('success', true)
        .addRedacted('userId', '123123', half)
        .addRedacted('to', '[email protected]', emailLocalHalf)
        .add('templateName', 'my-email-template')
        .log()
  //...
}

logs

[Nest] 7554 - 01/17/2021, 9:10:31 PM   [EmailService] send=email success=true userId=███123 to=████[email protected] templateName=my-email-template

Loglevels

FluentLogger supports same log levels as the Nest logger.

  logger.fluent()
        .add('success', true)
        .log() //.error() , .warn(), .debug(), .verbose()

Context

It accepts the same arguments as Nest, like e.g. Context. Just without the message part, which is generated through the key value pairs.

  logger.fluent()
        .add('success', true)
        .log(myContext)

Redaction Strategies

This package comes with a set of predefined redaction strategies. You can also provide you own.

| Strategy | Description | Using | Redacts to | | -------------- |------------------------------------------- |---------------------------------------------- | --------------| | fully (default) | redacts every char with a Bar | .addRedacted('to','Eddy') | ████ | | half | same as firstHalf | .addRedacted('to','Eddy', half) | ██dy | | firstHalf | redacts the first half with bars | .addRedacted('to','Eddy', firstHalf) | ██dy | | lastHalf | redacts the last half with bars | .addRedacted('to','Eddy', lastHalf) | Ed██ | | replaceWith | redacts with specified replacement | .addRedacted('to','Eddy', replaceWith('❤️')) | ❤️ | | emailLocal | redacts local part of email | .addRedacted('to','[email protected]', emailLocal) | ██@ab.c | | emailLocalHalf | redacts first half of local part of email | .addRedacted('to','[email protected]', emailLocalHalf) | █[email protected] | | emailDomain | redacts domain part of email | .addRedacted('to','[email protected]', emailDomain) | Ed@███ | | emailDomainHalf | redacts first half of domain part of email | .addRedacted('to','[email protected]', emailDomainHalf) | Ed@██.c |

Redaction strategies Composition

It is possible to compose redaction strategies, e.g.:

logger.fluent()
        .add('email','[email protected]', emailLocalHalf, emailDomainHalf) // this redacts  [email protected] to ██dy@██████le.com
        .log()

Usage as normal Nest Logger

FluentLogger is an extension of the default Nest Logger and supports all it's features.

import { FluentLogger } from '@kittgen/nestjs-fluent-logger';

const logger = new FluentLogger()
logger.log('hello world')

Local Development

Local Library Development

Important Commands


# start in watcher mode
npm start

# builds to the 'dist' folder
npm run build

# runs the tests
npm test

Commits

We use conventional commits for nice commit messages and automated versioning/changelog.

This packages uses TSDX.

License

Kittgen is licensed under MIT. See LICENSE.

Authors

Kittgen is developed by Otto von Wesendonk and Edgar Müller.