@umituz/react-native-design-system 4.23.120 → 4.23.122
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 +1 -1
- package/src/index.ts +6 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/logger.ts +144 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.122",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -102,6 +102,12 @@ export * from "./presentation/utils/variants";
|
|
|
102
102
|
// =============================================================================
|
|
103
103
|
export * from "./utilities";
|
|
104
104
|
|
|
105
|
+
// =============================================================================
|
|
106
|
+
// UTILS EXPORTS (Logger, formatters, validators)
|
|
107
|
+
// =============================================================================
|
|
108
|
+
export { logger, Logger } from "./utils/logger";
|
|
109
|
+
export type { LoggerConfig } from "./utils/logger";
|
|
110
|
+
|
|
105
111
|
// =============================================================================
|
|
106
112
|
// STORAGE EXPORTS
|
|
107
113
|
// =============================================================================
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Utility
|
|
3
|
+
* Production-safe logging that respects __DEV__ flag
|
|
4
|
+
* Logs are suppressed in production builds to reduce bundle size and improve performance
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable no-console */
|
|
8
|
+
|
|
9
|
+
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
10
|
+
|
|
11
|
+
interface LoggerConfig {
|
|
12
|
+
enableInProduction?: boolean;
|
|
13
|
+
errorTrackingService?: (error: unknown, context?: Record<string, unknown>) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class Logger {
|
|
17
|
+
private isDev: boolean;
|
|
18
|
+
private config: LoggerConfig;
|
|
19
|
+
|
|
20
|
+
constructor(config: LoggerConfig = {}) {
|
|
21
|
+
this.isDev = typeof __DEV__ !== "undefined" ? __DEV__ : false;
|
|
22
|
+
this.config = config;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Debug logging - only in development
|
|
27
|
+
* Use for detailed debugging information
|
|
28
|
+
*/
|
|
29
|
+
debug(...args: unknown[]): void {
|
|
30
|
+
if (this.isDev) {
|
|
31
|
+
console.log("[DEBUG]", ...args);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Info logging - only in development
|
|
37
|
+
* Use for general information
|
|
38
|
+
*/
|
|
39
|
+
info(...args: unknown[]): void {
|
|
40
|
+
if (this.isDev) {
|
|
41
|
+
console.info("[INFO]", ...args);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Warning logging - always shown
|
|
47
|
+
* Use for recoverable issues
|
|
48
|
+
*/
|
|
49
|
+
warn(...args: unknown[]): void {
|
|
50
|
+
console.warn("[WARN]", ...args);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Error logging - always shown
|
|
55
|
+
* Use for errors and exceptions
|
|
56
|
+
* In production, sends to error tracking service if configured
|
|
57
|
+
*/
|
|
58
|
+
error(...args: unknown[]): void {
|
|
59
|
+
console.error("[ERROR]", ...args);
|
|
60
|
+
|
|
61
|
+
// Send to error tracking in production
|
|
62
|
+
if (!this.isDev && this.config.errorTrackingService) {
|
|
63
|
+
const error = args[0];
|
|
64
|
+
const context = args.slice(1).reduce<Record<string, unknown>>((acc, arg, idx) => {
|
|
65
|
+
acc[`arg${idx}`] = arg;
|
|
66
|
+
return acc;
|
|
67
|
+
}, {});
|
|
68
|
+
|
|
69
|
+
this.config.errorTrackingService(error, context);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Group logging - only in development
|
|
75
|
+
* Use for grouping related logs
|
|
76
|
+
*/
|
|
77
|
+
group(label: string): void {
|
|
78
|
+
if (this.isDev && console.group) {
|
|
79
|
+
console.group(label);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* End group logging - only in development
|
|
85
|
+
*/
|
|
86
|
+
groupEnd(): void {
|
|
87
|
+
if (this.isDev && console.groupEnd) {
|
|
88
|
+
console.groupEnd();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Table logging - only in development
|
|
94
|
+
* Use for displaying tabular data
|
|
95
|
+
*/
|
|
96
|
+
table(data: unknown): void {
|
|
97
|
+
if (this.isDev && console.table) {
|
|
98
|
+
console.table(data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Time measurement - only in development
|
|
104
|
+
* Use for performance measurements
|
|
105
|
+
*/
|
|
106
|
+
time(label: string): void {
|
|
107
|
+
if (this.isDev && console.time) {
|
|
108
|
+
console.time(label);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* End time measurement - only in development
|
|
114
|
+
*/
|
|
115
|
+
timeEnd(label: string): void {
|
|
116
|
+
if (this.isDev && console.timeEnd) {
|
|
117
|
+
console.timeEnd(label);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Assert logging - only in development
|
|
123
|
+
* Use for assertions
|
|
124
|
+
*/
|
|
125
|
+
assert(condition: boolean, ...args: unknown[]): void {
|
|
126
|
+
if (this.isDev && console.assert) {
|
|
127
|
+
console.assert(condition, ...args);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Configure logger
|
|
133
|
+
*/
|
|
134
|
+
configure(config: LoggerConfig): void {
|
|
135
|
+
this.config = { ...this.config, ...config };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Default logger instance
|
|
140
|
+
export const logger = new Logger();
|
|
141
|
+
|
|
142
|
+
// Export class for custom instances
|
|
143
|
+
export { Logger };
|
|
144
|
+
export type { LoggerConfig };
|