@venizia/ignis-docs 0.0.4 → 0.0.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": "@venizia/ignis-docs",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Documentation and MCP Server for Ignis Framework",
5
5
  "keywords": [
6
6
  "ignis",
@@ -114,7 +114,7 @@
114
114
  "@braintree/sanitize-url": "^7.1.1",
115
115
  "@types/bun": "^1.3.4",
116
116
  "@types/glob": "^8.1.0",
117
- "@venizia/dev-configs": "^0.0.5",
117
+ "@venizia/dev-configs": "^0.0.6",
118
118
  "eslint": "^9.36.0",
119
119
  "glob": "^10.4.2",
120
120
  "prettier": "^3.6.2",
@@ -109,14 +109,17 @@ export class UserController extends BaseController {
109
109
 
110
110
  ## Performance Logging Pattern
111
111
 
112
- Use `performance.now()` for timing critical operations:
112
+ Use `performance.now()` for timing critical operations with method-scoped logging:
113
113
 
114
114
  ```typescript
115
- const t = performance.now();
115
+ async syncData() {
116
+ const t = performance.now();
117
+ this.logger.for('syncData').info('START | Syncing data...');
116
118
 
117
- // ... operation to measure ...
119
+ // ... operation to measure ...
118
120
 
119
- this.logger.info('[methodName] DONE | Took: %s (ms)', performance.now() - t);
121
+ this.logger.for('syncData').info('DONE | Took: %s (ms)', performance.now() - t);
122
+ }
120
123
  ```
121
124
 
122
125
  **With the helper utility:**
@@ -125,7 +128,7 @@ this.logger.info('[methodName] DONE | Took: %s (ms)', performance.now() - t);
125
128
  import { executeWithPerformanceMeasure } from '@venizia/ignis';
126
129
 
127
130
  await executeWithPerformanceMeasure({
128
- logger: this.logger,
131
+ logger: this.logger.for('syncData'),
129
132
  scope: 'DataSync',
130
133
  description: 'Sync user records',
131
134
  task: async () => {
@@ -135,6 +138,29 @@ await executeWithPerformanceMeasure({
135
138
  // Logs: [DataSync] Sync user records | Took: 1234.56 (ms)
136
139
  ```
137
140
 
141
+ **Method-scoped logging pattern:**
142
+
143
+ ```typescript
144
+ class UserService {
145
+ private logger = Logger.get('UserService');
146
+
147
+ async createUser(data: CreateUserDto) {
148
+ // Use .for() to add method context to all logs
149
+ this.logger.for('createUser').info('Creating user: %j', data);
150
+ // Output: [UserService-createUser] Creating user: {...}
151
+
152
+ try {
153
+ const user = await this.userRepo.create({ data });
154
+ this.logger.for('createUser').info('User created: %s', user.id);
155
+ return user;
156
+ } catch (error) {
157
+ this.logger.for('createUser').error('Failed: %s', error);
158
+ throw error;
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
138
164
  ## See Also
139
165
 
140
166
  - [Naming Conventions](./naming-conventions) - Class and file naming
@@ -354,6 +354,44 @@ setInterval(() => {
354
354
  }, 3600000); // Every hour
355
355
  ```
356
356
 
357
+ ## 10. High-Frequency Logging
358
+
359
+ For performance-critical applications like HFT systems, use `HfLogger` instead of standard logging.
360
+
361
+ ### Standard Logger vs HfLogger
362
+
363
+ | Feature | Standard Logger | HfLogger |
364
+ |---------|-----------------|----------|
365
+ | Latency | ~1-10 microseconds | ~100-300 nanoseconds |
366
+ | Allocation | Per-call string formatting | Zero in hot path |
367
+ | Use case | General application | Trading, real-time systems |
368
+
369
+ ### HfLogger Usage
370
+
371
+ ```typescript
372
+ import { HfLogger, HfLogFlusher } from '@venizia/ignis-helpers';
373
+
374
+ // At initialization (once):
375
+ const logger = HfLogger.get('OrderEngine');
376
+ const MSG_ORDER_SENT = HfLogger.encodeMessage('Order sent');
377
+ const MSG_ORDER_FILLED = HfLogger.encodeMessage('Order filled');
378
+
379
+ // Start background flusher
380
+ const flusher = new HfLogFlusher();
381
+ flusher.start(100); // Flush every 100ms
382
+
383
+ // In hot path (~100-300ns, zero allocation):
384
+ logger.log('info', MSG_ORDER_SENT);
385
+ logger.log('info', MSG_ORDER_FILLED);
386
+ ```
387
+
388
+ **Key points:**
389
+ - Pre-encode messages at initialization, not in hot path
390
+ - Use background flushing to avoid I/O blocking
391
+ - HfLogger uses a lock-free ring buffer (64K entries, 16MB)
392
+
393
+ > **Deep Dive:** See [Logger Helper](../references/helpers/logger.md) for complete HfLogger API.
394
+
357
395
  ## Performance Checklist
358
396
 
359
397
  | Category | Check | Impact |
@@ -367,6 +405,7 @@ setInterval(() => {
367
405
  | **Memory** | Large datasets processed in batches | High |
368
406
  | **Caching** | Expensive queries cached | High |
369
407
  | **Workers** | CPU-intensive tasks offloaded | High |
408
+ | **Logging** | HfLogger for hot paths (HFT) | High |
370
409
  | **Monitoring** | Performance logging enabled | Low |
371
410
 
372
411
  ## See Also
@@ -75,9 +75,30 @@ curl -H "Authorization: Bearer YOUR_TOKEN" \
75
75
  ## 5. General Debugging Tips
76
76
 
77
77
  **Enable detailed logging:**
78
+ ```bash
79
+ # Enable debug mode via environment variable
80
+ DEBUG=true
81
+ ```
82
+
83
+ **Use method-scoped logging with `.for()`:**
78
84
  ```typescript
79
- // Increase log verbosity
80
- LoggerFactory.setLevel('debug');
85
+ class UserService {
86
+ private logger = Logger.get('UserService');
87
+
88
+ async createUser(data: CreateUserDto) {
89
+ this.logger.for('createUser').info('Creating user: %j', data);
90
+ // Output: [UserService-createUser] Creating user: {...}
91
+
92
+ try {
93
+ const user = await this.userRepo.create({ data });
94
+ this.logger.for('createUser').info('User created: %s', user.id);
95
+ return user;
96
+ } catch (error) {
97
+ this.logger.for('createUser').error('Failed: %s', error);
98
+ throw error;
99
+ }
100
+ }
101
+ }
81
102
  ```
82
103
 
83
104
  **Common debugging commands:**
@@ -93,7 +114,7 @@ cat .env | grep APP_ENV
93
114
  ```
94
115
 
95
116
  **Useful debugging patterns:**
96
- - Add `console.log()` in route handlers to trace execution
117
+ - Use `logger.for('methodName')` to trace execution with method context
97
118
  - Use `try-catch` blocks to catch and log errors
98
119
  - Check database queries with Drizzle's logging: `{ logger: true }`
99
120