Skip to content

Commit

Permalink
feat: add traction functions (#1)
Browse files Browse the repository at this point in the history
* feat: add traction functions
---------

Signed-off-by: Jason C. Leach <[email protected]>
  • Loading branch information
jleach authored Jul 18, 2024
1 parent 09aa91b commit 66344ea
Show file tree
Hide file tree
Showing 4 changed files with 754 additions and 78 deletions.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
"@hyperledger/aries-askar-nodejs": "0.2.1",
"@hyperledger/indy-vdr-nodejs": "0.2.2",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"jimp": "^0.22.12",
"jsonwebtoken": "^9.0.2",
"moment-timezone": "^0.5.45",
"node-gyp": "^10.2.0",
"pino": "^8.21.0",
"qrcode": "^1.5.3"
"qrcode": "^1.5.3",
"qrcode-terminal": "^0.12.0"
},
"packageManager": "[email protected]",
"devDependencies": {
Expand All @@ -23,12 +28,15 @@
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9",
"@types/node": "^18.18.14",
"@types/qrcode": "^1.5.5",
"@types/qrcode-terminal": "^0",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.2",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
}
},
"version": "0.0.0"
}
64 changes: 64 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import pino, { Logger } from "pino";
import { LogLevel, BaseLogger } from "@credo-ts/core";
export { LogLevel } from "@credo-ts/core";

export const pertTransport = pino.transport({
targets: [
{
level: "trace",
target: "pino/file",
options: {
destination: "./log.perf.ndjson",
autoEnd: true,
},
},
],
});

export const loggerTransport = pino.transport({
targets: [
{
level: "trace",
target: "pino/file",
options: {
destination: "./log.ndjson",
autoEnd: true,
},
},
],
});

export const logger = pino(
{ level: "trace", timestamp: pino.stdTimeFunctions.isoTime },
loggerTransport
);

export class PinoLogger extends BaseLogger {
logger: Logger;
constructor(logger: Logger, logLevel: LogLevel) {
super(logLevel);
this.logger = logger;
}
test(message: string, data?: Record<string, any> | undefined): void {
this.logger.debug(data || {}, message);
}
trace(message: string, data?: Record<string, any> | undefined): void {
this.logger.trace(data || {}, message);
}
debug(message: string, data?: Record<string, any> | undefined): void {
this.logger.debug(data || {}, message);
}
info(message: string, data?: Record<string, any> | undefined): void {
this.logger.info(data || {}, message);
}
warn(message: string, data?: Record<string, any> | undefined): void {
this.logger.warn(data || {}, message);
}
error(message: string, data?: Record<string, any> | undefined): void {
this.logger.error(data || {}, message);
}
fatal(message: string, data?: Record<string, any> | undefined): void {
//console.dir(data)
this.logger.fatal(data || {}, message);
}
}
Loading

0 comments on commit 66344ea

Please sign in to comment.