@strkfarm/sdk 1.0.37 → 1.0.39

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.
@@ -1,3 +1,5 @@
1
+ export * from '@/utils/logger';
2
+
1
3
  // Utility type to make all optional properties required
2
4
  export type RequiredFields<T> = {
3
5
  [K in keyof T]-?: T[K]
@@ -0,0 +1,20 @@
1
+
2
+ interface LeveledLogMethod {
3
+ (message: string, ...meta: any[]): void;
4
+ (message: any): void
5
+ }
6
+
7
+ interface MyLogger {
8
+ error: LeveledLogMethod;
9
+ warn: LeveledLogMethod;
10
+ info: LeveledLogMethod;
11
+ verbose: LeveledLogMethod;
12
+ debug: LeveledLogMethod;
13
+ }
14
+
15
+ export const logger: MyLogger = {
16
+ ...console,
17
+ verbose(message: string) {
18
+ console.log(`[VERBOSE] ${message}`);
19
+ }
20
+ };
@@ -0,0 +1,35 @@
1
+ import winston, { format } from "winston";
2
+
3
+ const colors = {
4
+ error: "red",
5
+ warn: "yellow",
6
+ info: "blue",
7
+ verbose: "white",
8
+ debug: "white",
9
+ };
10
+
11
+ // Add custom colors to Winston
12
+ winston.addColors(colors);
13
+
14
+ export const logger = winston.createLogger({
15
+ level: "verbose", // Set the minimum logging level
16
+ format: format.combine(
17
+ format.colorize({ all: true }), // Apply custom colors
18
+ format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), // Add timestamp to log messages
19
+ format.printf(({ timestamp, level, message, ...meta }) => {
20
+ let msg = `${timestamp} ${level}: ${message}`;
21
+ // Print stack trace if error is passed
22
+ if (meta && meta[Symbol.for("splat")]) {
23
+ for (const arg of meta[Symbol.for("splat")]) {
24
+ if (arg instanceof Error) {
25
+ msg += `\n${arg.stack}`;
26
+ }
27
+ }
28
+ }
29
+ return msg;
30
+ })
31
+ ),
32
+ transports: [
33
+ new winston.transports.Console(), // Output logs to the console
34
+ ],
35
+ });
@@ -0,0 +1 @@
1
+ export * from '@/utils/logger.browser';
@@ -3,8 +3,8 @@ import fs, { readFileSync, writeFileSync } from 'fs';
3
3
  import { Account, constants } from 'starknet';
4
4
  import * as crypto from 'crypto';
5
5
  import { PasswordJsonCryptoUtil } from './encrypt';
6
- import { logger } from '..';
7
6
  import { log } from 'winston';
7
+ import { logger } from "@/utils/logger";
8
8
 
9
9
  /**
10
10
  * @description Config to manage storage of files on disk