1.5.2 • Published 1 year ago

@poap-xyz/poap-logger v1.5.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

💻 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

License

MIT © POAP

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago