Commit 1f1c6d4
authored
refactor(logging): migrate to singleton logger service (#207)
* 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]>
---------
Signed-off-by: Asitha de Silva <[email protected]>1 parent 1c6cf99 commit 1f1c6d4
File tree
37 files changed
+2458
-2915
lines changed- .vscode
- apps/lfx-one/src
- app/modules/meetings/components/meeting-card
- server
- controllers
- helpers
- middleware
- routes
- services
- utils
- docs/architecture/backend
37 files changed
+2458
-2915
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 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 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 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 | + | |
121 | 319 | | |
122 | 320 | | |
123 | 321 | | |
| |||
128 | 326 | | |
129 | 327 | | |
130 | 328 | | |
131 | | - | |
| 329 | + | |
132 | 330 | | |
133 | 331 | | |
134 | 332 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
| 476 | + | |
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
485 | | - | |
| 485 | + | |
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
| 497 | + | |
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| |||
0 commit comments