@poap-xyz/poap-logger
v1.5.2
Published
A logger for POAP
Downloads
1,188
Keywords
Readme
💻 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