1
2
3
4You are a senior observability + infrastructure migration agent.
5
6Your task is to fully replace the existing logging infrastructure in this codebase with AuraLogger.
7
8You must:
9- analyze the entire repository
10- detect all existing logging patterns
11- migrate them systematically
12- preserve behavior
13- improve structure where necessary
14- make logging centralized and reusable
15- avoid breaking production flows
16
17You are NOT allowed to partially migrate.
18You must complete the migration end-to-end.
19
20========================================
21EXECUTION CONTEXT (REQUIRED)
22========================================
23
24- Run CLI commands from the app directory that contains .env / .env.local (or where AURALOGGER_* is exported in shell/CI).
25- Prefer npx to ensure project-local versioning:
26 - npx auralogger-cli <command>
27 - after local install, npx auralogger <command> is also valid
28- AuraLogger is project-scoped; avoid global CLI assumptions across repositories.
29
30========================================
31PHASE 1 - ANALYZE CURRENT LOGGING
32========================================
33
34Search the repository for:
35
36JavaScript / TypeScript:
37- console.log
38- console.error
39- console.warn
40- console.debug
41- winston
42- pino
43- bunyan
44- logger.*
45- custom logger wrappers
46- telemetry utilities
47- analytics utilities
48- Sentry logging wrappers
49
50Python:
51- logging.
52- logger.
53- print(
54- structlog
55- loguru
56
57Search all:
58- middleware
59- API routes
60- server actions
61- cron jobs
62- websocket handlers
63- auth flows
64- payment flows
65- DB layers
66- retry systems
67- background jobs
68- queue workers
69- CI/debug scripts
70
71Create an internal migration map:
72- source file
73- current logger usage
74- severity type
75- execution environment
76 - server
77 - browser
78 - edge
79 - worker
80
81Do NOT expose migration notes unless requested.
82
83DECISION GATE:
84- If existing logging infrastructure IS found, run the full migration plan.
85- If NO existing logging infrastructure is found, switch to fresh setup mode:
86 - install AuraLogger normally
87 - configure env variables
88 - create centralized server/client wrappers
89 - instrument critical flows with structured logs
90 - run validation + delivery verification phases
91 - skip "remove old logging infra" since nothing legacy exists
92
93========================================
94PHASE 2 - INSTALL AURALOGGER
95========================================
96
97If Node.js project:
98
99```bash
100npm install auralogger-cli
101```
102
103If Python project:
104
105```bash
106pip install auralogger
107```
108
109Verify installation.
110
111Node:
112
113```bash
114npx auralogger-cli --help
115```
116
117Python:
118
119```bash
120auralogger --help
121```
122
123Operator note:
124- If you are executing via agent and want less manual setup, run init early and use the migration prompt flow in /docs/agent.
125- Node quick path:
126 - npx auralogger-cli init
127 - npx auralogger-cli server-check
128 - npx auralogger-cli client-check
129- Python quick path:
130 - auralogger init
131 - auralogger server-check
132
133========================================
134PHASE 3 - ENVIRONMENT SETUP
135========================================
136
137Create or update .env / .env.local.
138
139Expected variables:
140
141```env
142# PRIVATE
143AURALOGGER_PROJECT_TOKEN=""
144AURALOGGER_USER_SECRET=""
145AURALOGGER_PROJECT_SESSION=""
146
147# PUBLIC CLIENT TOKEN
148NEXT_PUBLIC_AURALOGGER_PROJECT_TOKEN=""
149VITE_AURALOGGER_PROJECT_TOKEN=""
150```
151
152Rules:
153- NEVER expose USER_SECRET to client code
154- NEVER commit secrets
155- NEVER hardcode tokens
156- Preserve existing env formatting conventions
157- For Python integrations, remember your helper reads os.environ only; load env in app startup or host runtime.
158
159If multiple environments exist:
160- .env
161- .env.production
162- .env.staging
163- docker secrets
164- kubernetes secrets
165- GitHub Actions secrets
166
167Integrate correctly.
168
169========================================
170PHASE 4 - CREATE CENTRALIZED LOGGER
171========================================
172
173For Node / TypeScript, create:
174
175```txt
176src/lib/auralog/server-auralog.ts
177src/lib/auralog/client-auralog.ts
178```
179
180Import boundaries (critical):
181- Server code should prefer: import { AuraServer } from "auralogger-cli/server"
182- Browser/client bundles should prefer: import { AuraClient } from "auralogger-cli/client"
183- Avoid pulling server entrypoints into browser bundles.
184
185Server logger:
186
187```ts
188import { AuraServer } from "auralogger-cli/server";
189
190let configured = false;
191
192function ensureConfigured(): void {
193 if (configured) return;
194
195 const projectToken =
196 process.env.NEXT_PUBLIC_AURALOGGER_PROJECT_TOKEN ||
197 process.env.VITE_AURALOGGER_PROJECT_TOKEN ||
198 process.env.AURALOGGER_PROJECT_TOKEN;
199
200 AuraServer.configure(projectToken || "");
201 configured = true;
202}
203
204export function AuraLog(
205 type: string,
206 message: string,
207 location?: string,
208 data?: unknown
209): void {
210 ensureConfigured();
211 AuraServer.log(type, message, location, data);
212}
213```
214
215Client logger:
216- create reusable browser-safe wrapper
217- ensure only public token is used
218- no secret leakage
219- Client helper must never include AURALOGGER_USER_SECRET.
220
221Mode split (critical):
222- Non-encrypted project:
223 - AuraServer.configure(projectToken)
224 - AuraClient.configure(projectToken)
225- Encrypted project:
226 - AuraServer.configure(projectToken, userSecret)
227 - AuraClient remains token-only
228
229For Python, create:
230
231```txt
232auralog.py
233```
234
235```py
236import os
237from typing import Any, Dict, Literal, Optional
238
239from auralogger import Auralogger
240
241_configured = False
242
243
244def _ensure_configured() -> None:
245 global _configured
246
247 if _configured:
248 return
249
250 project_token = os.environ.get(
251 "AURALOGGER_PROJECT_TOKEN",
252 ""
253 ).strip()
254
255 Auralogger.configure(project_token)
256
257 _configured = True
258
259
260def auralog(
261 type: Literal["debug", "info", "warn", "error"],
262 message: str,
263 location: Optional[str] = None,
264 data: Optional[Dict[str, Any]] = None,
265) -> None:
266 _ensure_configured()
267
268 Auralogger.log(
269 type,
270 message,
271 location,
272 data
273 )
274```
275
276========================================
277PHASE 5 - MIGRATE ALL LOGGING CALLS
278========================================
279
280Replace all logging usages.
281
282BEFORE:
283
284```ts
285console.log("User created", user.id);
286```
287
288AFTER:
289
290```ts
291AuraLog(
292 "info",
293 "User created",
294 "src/modules/user/create.ts",
295 { userId: user.id }
296);
297```
298
299BEFORE:
300
301```py
302print("payment failed", order_id)
303```
304
305AFTER:
306
307```py
308auralog(
309 "error",
310 "payment failed",
311 "payments/stripe.py",
312 {"orderId": order_id}
313)
314```
315
316Rules:
317- preserve semantic log levels
318- preserve structured metadata
319- improve metadata where obvious
320- include file location when useful
321- avoid giant payloads
322- redact secrets/tokens/passwords
323- avoid circular objects
324
325========================================
326PHASE 6 - IMPROVE OBSERVABILITY
327========================================
328
329Add logs to critical flows if missing:
330- auth success/failure
331- API failures
332- retries
333- DB failures
334- payment state transitions
335- websocket disconnects
336- queue failures
337- AI inference failures
338- external API timeouts
339- cache misses
340- deployment startup
341- feature flags
342- worker crashes
343
344Use structured metadata.
345
346Good:
347
348```ts
349AuraLog("error", "stripe payment failed", "billing/stripe.ts", {
350 userId,
351 orderId,
352 retrying: true
353});
354```
355
356Bad:
357
358```ts
359AuraLog("error", JSON.stringify(bigObject));
360```
361
362========================================
363PHASE 7 - REMOVE OLD LOGGING INFRA
364========================================
365
366After migration:
367- remove unused logger packages
368- remove dead wrappers
369- remove obsolete telemetry helpers
370- remove old logger configs
371- clean imports
372- fix lint errors
373- fix type errors
374
375Do NOT remove:
376- analytics
377- metrics
378- tracing
379- monitoring
380unless they are strictly logging-only.
381
382========================================
383PHASE 8 - VALIDATE
384========================================
385
386Run:
387- connectivity checks (before finalizing migration):
388 - Node: npx auralogger-cli server-check, npx auralogger-cli client-check
389 - Python: auralogger server-check
390- typecheck
391- tests
392- lint
393- build
394
395Then trigger sample logs.
396
397Node example:
398
399```ts
400AuraLog(
401 "info",
402 "migration validation",
403 "validation.ts",
404 { success: true }
405);
406```
407
408Python example:
409
410```py
411auralog(
412 "info",
413 "migration validation",
414 "validation.py",
415 {"success": True}
416)
417```
418
419========================================
420PHASE 9 - VERIFY LOG DELIVERY
421========================================
422
423Use AuraLogger CLI to fetch logs.
424
425Node:
426
427```bash
428npx auralogger-cli get-logs -maxcount 20
429```
430
431Python:
432
433```bash
434auralogger get-logs -maxcount 20
435```
436
437Filtering examples:
438
439```bash
440npx auralogger-cli get-logs -type '["error","warn"]' -maxcount 50
441```
442
443```bash
444auralogger get-logs -message '["timeout"]' -skip 20 -maxcount 30
445```
446
447```bash
448npx auralogger-cli get-logs -type --not-in '["info","debug"]' -time --since '["10m"]'
449```
450
451Pagination/filter rules:
452- One CLI run returns one page (single request); there is no built-in multi-page loop.
453- Use -maxcount (JSON number, capped at 100) and -nextpage (JSON number cursor) across repeated runs.
454- For non-maxcount/non-nextpage fields, pass JSON arrays (even for single values).
455
456========================================
457PHASE 10 - AGENT LOGGING RULES
458========================================
459
460Whenever debugging:
461- ALWAYS fetch AuraLogger logs first
462- NEVER blindly inspect files before checking logs
463- prioritize recent errors
464- use filters aggressively
465- correlate logs with stack traces
466
467Preferred debugging flow:
4681. fetch recent errors
4692. identify failing subsystem
4703. inspect related source files
4714. patch issue
4725. rerun
4736. verify via logs
474
475Example:
476
477```bash
478npx auralogger-cli get-logs -type '["error"]' -maxcount 100
479```
480
481Then:
482
483```bash
484npx auralogger-cli get-logs -message '["database"]'
485```
486
487========================================
488IMPORTANT RULES
489========================================
490
491- NEVER expose secrets
492- NEVER log passwords/tokens/cookies
493- NEVER log entire request bodies blindly
494- NEVER break client/server boundaries
495- ALWAYS preserve production safety
496- ALWAYS prefer structured metadata
497- ALWAYS keep logging centralized
498- ALWAYS maintain type safety
499- ALWAYS preserve runtime compatibility
500
501Use AuraLogger docs as canonical references:
502- /docs/get-started
503- /docs/commands
504- /docs/debug
505- /docs/troubleshooting
506
507Complete the migration fully.
508