generated from jasonsturges/typescript-npm-package
-
Notifications
You must be signed in to change notification settings - Fork 7
/
custom-logger.ts
39 lines (33 loc) · 976 Bytes
/
custom-logger.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { SpvWalletClient, generateKeys } from '../dist/typescript-npm-package.cjs.js';
const server = 'http://localhost:3003';
const newXPub = generateKeys().xPub.toString();
// Option 1 - control console log level
const clientWithCustomLogLevel = new SpvWalletClient(
server,
{
xPub: newXPub,
},
{
//default level is 'info'
level: 'debug', //available levels: 'debug' | 'info' | 'warn' | 'error' | 'disabled'
},
);
//this will log that the request is being made
await clientWithCustomLogLevel.GetTransactions({}, {}, {});
// Option 2 - provide your custom logger
class CustomLogger {
debug(msg: string, ...args: any[]) {
//do whatever you want
}
info(msg: string, ...args: any[]) {}
warn(msg: string, ...args: any[]) {}
error(msg: string, ...args: any[]) {}
}
const clientWithCustomLogger = new SpvWalletClient(
server,
{
xPub: newXPub,
},
new CustomLogger(),
);
await clientWithCustomLogger.GetTransactions({}, {}, {});