react-logger-app 1.1.3 → 1.1.4

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.
Files changed (2) hide show
  1. package/README.md +192 -69
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,46 +1,58 @@
1
1
  # ReactLoggerApp 🐞
2
2
 
3
- A professional, high-performance visual logging system for Ionic React applications. Monitor logs, errors, and JSON objects in real-time with a beautiful floating UI.
3
+ A professional, high-performance visual logging system for **Ionic React** applications. Monitor logs, errors, and JSON objects in real-time with a beautiful floating UI that works seamlessly on **iOS**, **Android**, and **Web**.
4
4
 
5
- ## Features
5
+ ![npm version](https://img.shields.io/npm/v/react-logger-app)
6
+ ![license](https://img.shields.io/npm/l/react-logger-app)
7
+ ![downloads](https://img.shields.io/npm/dm/react-logger-app)
6
8
 
7
- - **Three Log Levels**: Debug, Error, and Object.
8
- - 🐞 **Floating UI**: Draggable, minimizable, and responsive button.
9
- - 📦 **JSON Tree Viewer**: Expandable visualization for complex objects.
10
- - 💾 **Persistence**: Option to store logs in `localStorage` or `IndexedDB`.
11
- - 🔍 **Search & Filters**: Quickly find specific logs or filter by level.
12
- - 📥 **Export**: Download logs as JSON files.
13
- - 🌓 **Dark Mode**: Automatic support for system theme.
14
- - 🚀 **Virtualized List**: Handles thousands of logs without performance loss.
9
+ ## Features
15
10
 
16
- ## Installation
11
+ - 🐞 **Three Log Levels**: Debug, Error, and Object
12
+ - � **Mobile-First Design**: Optimized for iOS and Android (WebView compatible)
13
+ - 🎨 **Liquid Glass UI**: Premium glassmorphism design with neon accents
14
+ - 🖱️ **Draggable Floating Button**: Minimizable, repositionable trigger
15
+ - 📦 **JSON Tree Viewer**: Expandable visualization for complex objects
16
+ - 💾 **Persistent Storage**: Save logs across sessions (localStorage/IndexedDB)
17
+ - 🔍 **Search & Filters**: Quickly find specific logs or filter by level
18
+ - 📥 **Export Logs**: Download as JSON files
19
+ - 🚀 **Virtualized List**: Handles thousands of logs without performance loss
20
+ - 🌐 **Cross-Platform**: Works in React components and TypeScript classes
21
+ - 🎯 **Zero Dependencies**: Lightweight with minimal peer dependencies
22
+
23
+ ## 📦 Installation
17
24
 
18
25
  ```bash
19
26
  npm install react-logger-app
20
27
  # or
21
28
  yarn add react-logger-app
29
+ # or
30
+ pnpm add react-logger-app
22
31
  ```
23
32
 
24
- ## Setup
33
+ ## 🚀 Quick Start
25
34
 
26
- Wrap your application with the `LoggerProvider` and add the `LoggerViewer` component (ideally in your `App.tsx`).
35
+ ### 1. Setup Provider
36
+
37
+ Wrap your application with `LoggerProvider` and add `LoggerViewer` (typically in `App.tsx`):
27
38
 
28
39
  ```tsx
29
40
  import { LoggerProvider, LoggerViewer } from 'react-logger-app';
41
+ import { IonApp } from '@ionic/react';
30
42
 
31
43
  const App: React.FC = () => (
32
44
  <LoggerProvider config={{ persistence: true, maxLogs: 1000 }}>
33
45
  <IonApp>
34
- {/* Your app components */}
46
+ {/* Your app routes and components */}
35
47
  <LoggerViewer />
36
48
  </IonApp>
37
49
  </LoggerProvider>
38
50
  );
39
- ```
40
51
 
41
- ## Usage
52
+ export default App;
53
+ ```
42
54
 
43
- Use the `useLogger` hook anywhere in your components.
55
+ ### 2. Use in React Components
44
56
 
45
57
  ```tsx
46
58
  import { useLogger } from 'react-logger-app';
@@ -48,12 +60,12 @@ import { useLogger } from 'react-logger-app';
48
60
  const MyComponent: React.FC = () => {
49
61
  const { debug, error, object } = useLogger();
50
62
 
51
- const handleAction = () => {
63
+ const handleAction = async () => {
52
64
  debug('Process started');
53
65
 
54
66
  try {
55
- const userData = { id: 1, name: 'John Doe', roles: ['admin', 'user'] };
56
- object(userData, 'User Data');
67
+ const response = await fetchData();
68
+ object(response, 'API Response');
57
69
  } catch (e) {
58
70
  error(e as Error);
59
71
  }
@@ -63,67 +75,178 @@ const MyComponent: React.FC = () => {
63
75
  };
64
76
  ```
65
77
 
66
- ### Usage in TypeScript Classes
78
+ ### 3. Use in TypeScript Classes
67
79
 
68
- You can also use the logger outside of React components (e.g., in services, helpers, or business logic classes).
80
+ Perfect for services, utilities, and business logic outside React:
69
81
 
70
82
  ```tsx
71
83
  import { Logger } from 'react-logger-app';
72
84
 
73
- class MyService {
74
- doWork() {
75
- Logger.debug('Starting work...', 'MyService');
85
+ class AuthService {
86
+ async login(credentials: Credentials) {
87
+ Logger.debug('Login attempt started', 'AuthService');
76
88
 
77
89
  try {
78
- // Logic
79
- Logger.object({ status: 'ok' }, 'Service Result');
80
- } catch (e) {
81
- Logger.error(e as Error);
90
+ const user = await api.authenticate(credentials);
91
+ Logger.object(user, 'Authenticated User');
92
+ return user;
93
+ } catch (error) {
94
+ Logger.error(error as Error);
95
+ throw error;
82
96
  }
83
97
  }
84
98
  }
85
99
  ```
86
100
 
87
- > [!NOTE]
88
- > Logs sent via `Logger` will be buffered if the `LoggerProvider` is not yet mounted and will be flushed as soon as the UI is ready.
101
+ > **Note**: Logs sent via `Logger` before the provider mounts are buffered and displayed once the UI is ready.
89
102
 
90
- ### Configuration Options
103
+ ## ⚙️ Configuration Options
91
104
 
92
105
  | Option | Type | Default | Description |
93
- | --- | --- | --- | --- |
94
- | `persistence` | `boolean` | `false` | Enable log storage between sessions. |
95
- | `persistenceDriver` | `'localStorage' \| 'indexedDB'` | `'localStorage'` | Choose where to store logs. |
96
- | `maxLogs` | `number` | `500` | Maximum number of logs to keep. |
97
- | `onLogAdded` | `(log: LogEntry) => void` | `undefined` | Callback fired every time a log is added. |
98
-
99
- ## Local Development & Demo
100
-
101
- To see the Liquid Glass logger in action within a sample Ionic React environment:
102
-
103
- 1. **Build the Library**:
104
- ```bash
105
- npm run build
106
- ```
107
- 2. **Run the Demo**:
108
- ```bash
109
- cd example
110
- npm install
111
- npm run dev
112
- ```
113
- 3. **View**: Open `http://localhost:5173` in your browser.
114
-
115
- ## API Reference
116
-
117
- ### `useLogger()`
118
- Returns:
119
- - `debug(message: string)`: Log a debug message.
120
- - `error(message: string | Error)`: Log an error or Error object.
121
- - `object(obj: any, title?: string)`: Log a serializable object.
122
- - `clear()`: Delete all current logs.
123
- - `exportLogs()`: Get an array of all `LogEntry` objects.
124
- - `logs`: Current array of logs.
125
- - `unreadCount`: Number of logs added while panel was closed.
126
-
127
- ## License
128
-
129
- MIT
106
+ |--------|------|---------|-------------|
107
+ | `persistence` | `boolean` | `false` | Enable log storage between sessions |
108
+ | `persistenceDriver` | `'localStorage'` \| `'indexedDB'` | `'localStorage'` | Storage backend for persisted logs |
109
+ | `maxLogs` | `number` | `500` | Maximum number of logs to retain |
110
+ | `onLogAdded` | `(log: LogEntry) => void` | `undefined` | Callback fired when a log is added |
111
+
112
+ ### Example with Custom Config
113
+
114
+ ```tsx
115
+ <LoggerProvider
116
+ config={{
117
+ persistence: true,
118
+ persistenceDriver: 'indexedDB',
119
+ maxLogs: 2000,
120
+ onLogAdded: (log) => {
121
+ if (log.level === 'ERROR') {
122
+ // Send to analytics or crash reporting
123
+ analytics.trackError(log);
124
+ }
125
+ }
126
+ }}
127
+ >
128
+ <App />
129
+ </LoggerProvider>
130
+ ```
131
+
132
+ ## 📱 Platform Support
133
+
134
+ ### Fully Tested On:
135
+ - **iOS** (Safari, WKWebView)
136
+ - **Android** (Chrome WebView, System WebView)
137
+ - **Web** (Chrome, Safari, Firefox, Edge)
138
+
139
+ ### 🔧 Android-Specific Optimizations (v1.1.3+)
140
+ - Solid background fallback for WebView compatibility
141
+ - Disabled `backdrop-filter` on mobile to prevent rendering artifacts
142
+ - Conditional rendering to avoid z-index conflicts
143
+ - No animations on small screens for smoother performance
144
+
145
+ ## 🎨 UI Features
146
+
147
+ ### Floating Button
148
+ - **Draggable**: Reposition anywhere on screen
149
+ - **Badge Counter**: Shows unread log count
150
+ - **Auto-hide**: Disappears when panel is open (prevents visual conflicts)
151
+ - **Persistent Position**: Remembers location after drag
152
+
153
+ ### Log Panel
154
+ - **Full-screen on Mobile**: Optimized for small screens
155
+ - **Virtualized Scrolling**: Smooth performance with 1000+ logs
156
+ - **Search Bar**: Filter logs by message or title
157
+ - **Level Filters**: Show only DEBUG, ERROR, or OBJECT logs
158
+ - **Export Button**: Download logs as JSON
159
+ - **Clear Button**: Remove all logs with confirmation
160
+
161
+ ## 📖 API Reference
162
+
163
+ ### `useLogger()` Hook
164
+
165
+ Returns an object with the following methods:
166
+
167
+ ```tsx
168
+ const {
169
+ debug, // (message: string) => void
170
+ error, // (message: string | Error) => void
171
+ object, // (obj: any, title?: string) => void
172
+ clear, // () => void
173
+ exportLogs, // () => LogEntry[]
174
+ logs, // LogEntry[]
175
+ unreadCount // number
176
+ } = useLogger();
177
+ ```
178
+
179
+ ### `Logger` Static Class
180
+
181
+ For use outside React components:
182
+
183
+ ```tsx
184
+ Logger.debug(message: string, title?: string): void
185
+ Logger.error(error: Error | string, title?: string): void
186
+ Logger.object(data: any, title?: string): void
187
+ ```
188
+
189
+ ### `LogEntry` Type
190
+
191
+ ```tsx
192
+ interface LogEntry {
193
+ id: string;
194
+ timestamp: string;
195
+ level: 'DEBUG' | 'ERROR' | 'OBJECT';
196
+ message: string;
197
+ title?: string;
198
+ data?: any;
199
+ stack?: string;
200
+ }
201
+ ```
202
+
203
+ ## 🛠️ Local Development
204
+
205
+ To run the demo app and test the logger:
206
+
207
+ ```bash
208
+ # 1. Build the library
209
+ npm run build
210
+
211
+ # 2. Run the example app
212
+ cd example
213
+ npm install
214
+ npm run dev
215
+
216
+ # 3. Open http://localhost:5173
217
+ ```
218
+
219
+ ## 🐛 Troubleshooting
220
+
221
+ ### Button not visible on Android
222
+ - **Solution**: Update to v1.1.3+ which includes Android-specific fixes
223
+ - Ensure `LoggerViewer` is placed inside `IonApp` or at root level
224
+ - Check z-index conflicts with other fixed/absolute positioned elements
225
+
226
+ ### Logs not persisting
227
+ - Verify `persistence: true` in config
228
+ - Check browser storage permissions
229
+ - For IndexedDB, ensure browser supports it
230
+
231
+ ### Performance issues with many logs
232
+ - Reduce `maxLogs` config value
233
+ - Use `clear()` periodically
234
+ - Enable persistence and restart app to clear memory
235
+
236
+ ## 📄 License
237
+
238
+ MIT © [Reinner Leiva](https://github.com/raysdl9012)
239
+
240
+ ## 🤝 Contributing
241
+
242
+ Contributions are welcome! Please open an issue or submit a pull request.
243
+
244
+ ## 📦 Package Info
245
+
246
+ - **Package**: `react-logger-app`
247
+ - **Repository**: [github.com/raysdl9012/react-logger](https://github.com/raysdl9012/react-logger)
248
+ - **NPM**: [npmjs.com/package/react-logger-app](https://www.npmjs.com/package/react-logger-app)
249
+
250
+ ---
251
+
252
+ Made with ❤️ for the Ionic React community
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-logger-app",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "A professional visual logging system for Ionic React applications.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",