DataFed icon indicating copy to clipboard operation
DataFed copied to clipboard

Epic - [ArangoDB] Logging improvements

Open megatnt1122 opened this issue 5 months ago • 5 comments

Arango is outputting non-useful logs that do not provide any helpful feedback so they will be removed.

megatnt1122 avatar Jul 21 '25 18:07 megatnt1122

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

JoshuaSBrown avatar Aug 12 '25 17:08 JoshuaSBrown

https://github.com/ORNL/DataFed/issues/812

JoshuaSBrown avatar Aug 12 '25 17:08 JoshuaSBrown

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

megatnt1122 avatar Aug 21 '25 16:08 megatnt1122

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");

megatnt1122 avatar Aug 21 '25 18:08 megatnt1122

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

megatnt1122 avatar Aug 21 '25 19:08 megatnt1122