@poap-xyz/poap-logger
Advanced tools
Comparing version
{ | ||
"name": "@poap-xyz/poap-logger", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "A logger for POAP", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -1,37 +0,39 @@ | ||
# 💻 POAP - Logger📜 | ||
# 💻 POAP Logger 📜 | ||
## Intro | ||
A logger with a simple facade to use in the POAP ecosystem. | ||
## Project | ||
This project was built with Typescript. | ||
## Usage | ||
## Usage | ||
### Setup | ||
Install from npm repository: | ||
Install from NPM repository: | ||
``` | ||
yarn add @poap-xyz/poap-logger | ||
``` | ||
### Logger Creation | ||
Example usage with the Fastify onRequest hook: | ||
```javascript | ||
export default function onRequest(this: FastifyInstance, request: FastifyRequest<any>, response: FastifyReply<any>, done: (err?: Error) => void) { | ||
const logger = PoapLoggerFactory.createLoggerInstance({ | ||
metadata: {/*METADATA*/} | ||
}); | ||
import { PoapLoggerFactory } from '@poap-xyz/poap-logger'; | ||
const logger = PoapLoggerFactory.createLoggerInstance({ | ||
metadata: {/*METADATA*/} | ||
}); | ||
``` | ||
Where METADATA is a key value pair object where you add the properties you want to log, eg: | ||
Where METADATA is a key value pair object where you add extra properties you want to log, eg: | ||
```javascript | ||
metadata: { | ||
const logger = PoapLoggerFactory.createLoggerInstance({ | ||
metadata: { | ||
requestId: request.headers["requestid"], | ||
requestUrl: request.url, | ||
source: "POAP-Logger-Parent" | ||
} | ||
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. | ||
```javascript | ||
@@ -44,17 +46,12 @@ PoapLoggerFactory.getLoggerInstance({ | ||
### Child Loggers | ||
Create a child logger to override or combine parent child metadata: | ||
```javascript | ||
logger.child({ | ||
moreMetadata1: "More meta", //Will be added | ||
source: "POAP-Logger-Child" //Will override parent's source prop | ||
const newLogger = 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 | ||
@@ -104,2 +101,3 @@ <!-- ALL-CONTRIBUTORS-LIST:END --> | ||
## License | ||
MIT © **[`POAP`](https://poap.xyz)** |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
22123
-0.79%102
-1.92%1
Infinity%