@poap-xyz/poap-logger
TypeScript icon, indicating that this package has built-in type declarations

1.5.2 • Public • Published

💻 POAP - Logger📜

Intro

A logger with a simple facade to use in the POAP ecosystem.

Project

This project was built with Typescript.

Usage

Setup

Install from npm repository:

yarn add @poap-xyz/poap-logger

Logger Creation

Example usage with the Fastify onRequest hook:

export default function onRequest(this: FastifyInstance, request: FastifyRequest<any>, response: FastifyReply<any>, done: (err?: Error) => void) {
  const logger = PoapLoggerFactory.createLoggerInstance({
    metadata: {/*METADATA*/}
  });

Where METADATA is a key value pair object where you add the properties you want to log, eg:

metadata: {
    requestId: request.headers["requestid"],
    requestUrl: request.url,
    source: "POAP-Logger-Parent"
}

You can also use getLoggerInstance which will get a logger instance if one is already created or create a new one if not.

PoapLoggerFactory.getLoggerInstance({
  metadata: {/*METADATA*/}
});

Child Loggers

Create a child logger to override or combine parent child metadata:

logger.child({
    moreMetadata1: "More meta", //Will be added
    source: "POAP-Logger-Child" //Will override parent's source prop
});

Logger Types

Coming soon

Logger Transports

Coming soon

Active contributors


Ignacio Negro Caino

💻

Eduardo Sacco

💻

Agustin Lavarello

💻

License

MIT © POAP

Readme

Keywords

none

Package Sidebar

Install

npm i @poap-xyz/poap-logger

Weekly Downloads

143

Version

1.5.2

License

ISC

Unpacked Size

22.3 kB

Total Files

17

Last publish

Collaborators

  • frannx1
  • guide42
  • rlajous
  • aguspoap
  • nachonnc