Epic - [ArangoDB] Logging improvements
Arango is outputting non-useful logs that do not provide any helpful feedback so they will be removed.
Useful
Step 1. Remove useless logs Step 2. Come up with standardized format
- Who (client id) - not name
- What - what action are they doing - (Include correlation id if one exists)
- Where - what file and function
- When - when are they running the request
- Outcome - was their request success or failure. if Faiulre what is the error
Best practice - don't include everything
- Each foxx route, before most action is taken
- Each foxx route, after the outcome is known.
Step 3 Introduce logs one foxx router file at a time
https://github.com/ORNL/DataFed/issues/812
console.log( "User_ID:",user?._id || "unknown", "What:", req.route?.path || req.originalUrl, "Where:", getCallerLocation(), "Time:", new Date().toLocaleString("en-US", { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false}), "S tatus", "started/failure/success");
First iteration of the format im planning to use, will be reviewed and changed quite a lot before being finalized, but this is the rough start
Try to create a padding for the logging:
console.info( "Client:",user?._id || "unknown", "Correlation_ID:", "unknown", "HTTP:","GET", "Route:", "usr/token/get/", "Status:", "Started", "Desc:", "Getting User Token");
console.info( "Client:",user?._id || "unknown", "|", "Correlation_ID:", "unknown", "|", "HTTP:","GET", "|", "Route:", "usr/token/get/", "|", "Status:", "Failure", "|", "Desc:", "Getting User Token", "|", "Err:", e.message || e, "|", "Stack:", e.stack || "No Stack Trace");
Latest format Client: unknown | Correlation_ID: unknown | HTTP: GET | Route: usr/token/get/ | Status: Failure | Desc: Getting User Token | Err: [ 2, "No such user 'u/amh107'" ] | Stack: No Stack Trace