@bsv/wallet-toolbox 1.7.3 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/wallet-toolbox",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
@@ -7,6 +7,7 @@ export class WalletLogger implements WalletLoggerInterface {
7
7
  isOrigin: boolean = true
8
8
  isError: boolean = false
9
9
  level?: WalletLoggerLevel
10
+ flushFormat?: 'json'
10
11
 
11
12
  constructor(log?: string | WalletLoggerInterface) {
12
13
  if (log) {
@@ -107,7 +108,11 @@ export class WalletLogger implements WalletLoggerInterface {
107
108
  }
108
109
 
109
110
  flush(): object | undefined {
110
- const log = this.toLogString()
111
+ const trace = this.toLogString()
112
+ const log = this.flushFormat === 'json' ? JSON.stringify({
113
+ name: 'WalletLogger.flush',
114
+ trace
115
+ }) : trace
111
116
  if (this.isError) console.error(log)
112
117
  else console.log(log)
113
118
  const r = this.isOrigin ? undefined : this.toWalletLoggerJson()
@@ -165,3 +170,37 @@ export function logCreateActionArgs(args: CreateActionArgs): object {
165
170
  * 'trace' Instead of adding debug details, focus on execution path and timing.
166
171
  */
167
172
  export type WalletLoggerLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace'
173
+
174
+ /**
175
+ * Constructor properties available to `WalletLogger`
176
+ */
177
+ export interface WalletLoggerArgs {
178
+ /**
179
+ * Optional. Logging levels that may influence what is logged.
180
+ *
181
+ * 'error' Only requests resulting in an exception should be logged.
182
+ * 'warn' Also log requests that succeed but with an abnormal condition.
183
+ * 'info' Also log normal successful requests.
184
+ * 'debug' Add input parm and result details where possible.
185
+ * 'trace' Instead of adding debug details, focus on execution path and timing.
186
+ */
187
+ level?: 'error' | 'warn' | 'info' | 'debug' | 'trace'
188
+
189
+ /**
190
+ * Valid if an accumulating logger. Count of `group` calls without matching `groupEnd`.
191
+ */
192
+ indent?: number
193
+ /**
194
+ * True if this is an accumulating logger and the logger belongs to the object servicing the initial request.
195
+ */
196
+ isOrigin?: boolean
197
+ /**
198
+ * True if this is an accumulating logger and an error was logged.
199
+ */
200
+ isError?: boolean
201
+
202
+ /**
203
+ * Optional array of accumulated logged data and errors.
204
+ */
205
+ logs?: WalletLoggerLog[]
206
+ }
package/src/index.all.ts CHANGED
@@ -22,5 +22,6 @@ export * from './wab-client/auth-method-interactors/TwilioPhoneInteractor'
22
22
  export * from './wab-client/auth-method-interactors/DevConsoleInteractor'
23
23
  export * from './wab-client/WABClient'
24
24
  export * from './Wallet'
25
+ export * from './WalletLogger'
25
26
  export * from './WalletAuthenticationManager'
26
27
  export * from './WalletPermissionsManager'
@@ -20,5 +20,6 @@ export * from './wab-client/auth-method-interactors/TwilioPhoneInteractor'
20
20
  export * from './wab-client/auth-method-interactors/DevConsoleInteractor'
21
21
  export * from './wab-client/WABClient'
22
22
  export * from './Wallet'
23
+ export * from './WalletLogger'
23
24
  export * from './WalletAuthenticationManager'
24
25
  export * from './WalletPermissionsManager'