Commit 1cb6ac8
authored
refactor(logging): fix duplicate logging and add service visibility (#210)
* refactor(logging): migrate to singleton logger service
- Created LoggerService singleton with WeakMap-based operation tracking
- Prevents duplicate logs and memory leaks
- CloudWatch-optimized structured JSON logging
- Updated 10 controllers, 2 middleware, 7 services, 2 utils
- Improved error handling with centralized error middleware logging
- Removed redundant error logs before next(error) calls
- Net reduction of 706 lines
LFXV2-903
Generated with [Claude Code](https://claude.ai/code)
Signed-off-by: Asitha de Silva <[email protected]>
* refactor(logging): extend logger service for infrastructure operations
Extended LoggerService to support both request-scoped and infrastructure
operations by making req parameter optional. Migrated all 41 direct
serverLogger calls across services, utilities, and routes to use the
unified logger service pattern.
Changes:
- Extended LoggerService methods to accept Request | undefined
- Migrated 11 request-scoped operations to pass req parameter
- Migrated 30 infrastructure operations to use logger with undefined
- Updated ai.service, user.service, project.service method signatures
- Replaced serverLogger calls in nats, snowflake, lock-manager services
- Updated CLAUDE.md with comprehensive logging documentation
- Removed serverLogger imports from all service/utility files
Benefits:
- Unified logging interface for all operations
- Better request correlation when context available
- Consistent error handling with err field
- Infrastructure operations now use same pattern
LFXV2-903
Signed-off-by: Asitha de Silva <[email protected]>
* docs(logging): update docs for infrastructure logging
Updated logging-monitoring.md to reflect the new dual-mode logger service
that supports both request-scoped and infrastructure operations. Added
documentation for the new server-logger.ts file that breaks the circular
dependency between server.ts and logger.service.ts.
Changes:
- Added logging architecture layers diagram showing server-logger.ts
- Updated all method signatures to show req | undefined pattern
- Added infrastructure logging examples for all methods
- Documented circular dependency resolution
- Clarified when to use request-scoped vs infrastructure logging
LFXV2-903
Signed-off-by: Asitha de Silva <[email protected]>
* refactor(meetings): move agenda generation to controller
Moved AI agenda generation logic from inline route handler to
MeetingController.generateAgenda method for better separation of concerns
and consistency with other route patterns.
Also improved logger usage in middleware and services:
- auth.middleware: better error tracking with startTime
- error-handler.middleware: use operation startTime when available
- access-check.service: move startOperation before try block
- etag.service: use debug instead of silent startOperation
- persona-helper: use success/error instead of warning
LFXV2-903
Signed-off-by: Asitha de Silva <[email protected]>
* docs(logging): update architecture diagram for server-logger
Updated CLAUDE.md logging architecture diagram to reflect the new
server-logger.ts file that breaks the circular dependency between
server.ts and logger.service.ts.
LFXV2-903
Signed-off-by: Asitha de Silva <[email protected]>
* fix: claude.md linting issues
Signed-off-by: Asitha de Silva <[email protected]>
* refactor(meetings): standardize generateAgenda error handling
LFXV2-903
Use ServiceValidationError.fromFieldErrors() and next() for validation
errors instead of manual 400 response, consistent with other controller
methods. Provides field-level error details and centralized error
handling through middleware.
Signed-off-by: Asitha de Silva <[email protected]>
* fix: linting issues for docs
Signed-off-by: Asitha de Silva <[email protected]>
* refactor(logging): fix duplicate logging and add service visibility
- Added logger.info() method for significant business operations
- Fixed 8 duplicate startOperation calls in meeting service
- Added comprehensive logging to 7 methods without logging
- Enhanced access-check service with debug logging
- Updated CLAUDE.md with logging layer responsibility guidelines
Pattern established:
- Controllers: startOperation/success/error for HTTP operations
- Services: debug for tracing, info for significant operations, warning for graceful errors
Impact: Eliminated 32 duplicate log entries, added production visibility for
V1→V2 transformations and data enrichment operations
JIRA: LFXV2-903
Signed-off-by: Asitha de Silva <[email protected]>
* refactor(logging): fix processRegistrantOperations error logging
- Remove unused _startTime parameter from method signature
- Add proper error logging for 403 and partial failure scenarios
- Update all call sites to remove startTime parameter
- Follow logging standards with err field and structured metadata
Generated with [Claude Code](https://claude.ai/code)
Signed-off-by: Asitha de Silva <[email protected]>
---------
Signed-off-by: Asitha de Silva <[email protected]>1 parent 19f0164 commit 1cb6ac8
File tree
5 files changed
+293
-113
lines changed- apps/lfx-one/src/server
- controllers
- services
5 files changed
+293
-113
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
142 | 171 | | |
143 | 172 | | |
144 | 173 | | |
| |||
165 | 194 | | |
166 | 195 | | |
167 | 196 | | |
168 | | - | |
| 197 | + | |
169 | 198 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
173 | 205 | | |
174 | 206 | | |
175 | 207 | | |
176 | | - | |
| 208 | + | |
177 | 209 | | |
178 | 210 | | |
| 211 | + | |
179 | 212 | | |
180 | | - | |
| 213 | + | |
181 | 214 | | |
| 215 | + | |
| 216 | + | |
182 | 217 | | |
183 | 218 | | |
184 | | - | |
| 219 | + | |
185 | 220 | | |
186 | 221 | | |
187 | 222 | | |
188 | 223 | | |
| 224 | + | |
189 | 225 | | |
190 | 226 | | |
191 | 227 | | |
| |||
246 | 282 | | |
247 | 283 | | |
248 | 284 | | |
249 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
250 | 334 | | |
251 | 335 | | |
252 | | - | |
253 | | - | |
| 336 | + | |
| 337 | + | |
254 | 338 | | |
255 | 339 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
260 | 347 | | |
261 | 348 | | |
262 | | - | |
263 | | - | |
264 | | - | |
| 349 | + | |
265 | 350 | | |
266 | | - | |
267 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
268 | 356 | | |
269 | 357 | | |
270 | 358 | | |
| |||
311 | 399 | | |
312 | 400 | | |
313 | 401 | | |
314 | | - | |
| 402 | + | |
315 | 403 | | |
316 | | - | |
| 404 | + | |
317 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
318 | 414 | | |
319 | 415 | | |
320 | 416 | | |
| |||
Lines changed: 18 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 429 | + | |
| 430 | + | |
437 | 431 | | |
438 | 432 | | |
439 | 433 | | |
| |||
527 | 521 | | |
528 | 522 | | |
529 | 523 | | |
530 | | - | |
| 524 | + | |
531 | 525 | | |
532 | 526 | | |
533 | 527 | | |
| |||
616 | 610 | | |
617 | 611 | | |
618 | 612 | | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
| 613 | + | |
| 614 | + | |
627 | 615 | | |
628 | 616 | | |
629 | 617 | | |
| |||
1232 | 1220 | | |
1233 | 1221 | | |
1234 | 1222 | | |
1235 | | - | |
1236 | 1223 | | |
1237 | 1224 | | |
1238 | 1225 | | |
| |||
1268 | 1255 | | |
1269 | 1256 | | |
1270 | 1257 | | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
1271 | 1263 | | |
1272 | 1264 | | |
1273 | 1265 | | |
1274 | 1266 | | |
1275 | 1267 | | |
1276 | | - | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
1277 | 1276 | | |
1278 | 1277 | | |
1279 | 1278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
363 | 399 | | |
364 | 400 | | |
365 | 401 | | |
| |||
0 commit comments