Skip to content

Clean up development-time log output of yarn dev #6788

@rikukissa

Description

@rikukissa

Description

In the current form of all Docker images and services printing log output to just one terminal window, we need to aggressively filter out everything not relevant for debugging and understanding why the stack is not working.

Let's start with an almost clean slate and filter out everything that is not an error. In practice this means:

  • Disabling hapi-pino in development (process.env.NODE_ENV !== 'production') for all packages in core + country config
  • Configuring our own logger to only print out logger.info and above level
  • Aggressively limiting log output of Docker dependencies

As an example instead of seeing a lot of this

@opencrvs/metrics: {"level":50,"time":1713185286493,"pid":89107,"hostname":"MacBook-Pro-16-inch-223
1.local","req":{"id":"1713185286489:MacBook-Pro-16-inch-2231.local:89107:lv0oxjq
2:10135","method":"post","url":"/audit/events","headers":{"content-type":"applic
ation/json","authorization":"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJze
XNhZG1pbiIsIm5hdGxzeXNhZG1pbiIsImRlbW8iXSwiaWF0IjoxNzEzMTg0ODY1LCJleHAi
OjE3MTM3ODk2NjUsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW
1nbnQtdXeS11c2VyIiwib3BlbmNydnM6bm90aWZpY
2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiL
CJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY
3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVud
HMtdXNlciJdLCJpc3MiOiZpY2UiLCJzdWIiOiI2NjFkMTIwNWZlYThiZDg1NTI5NTBlYjgifQ.pKM11RK4HU
guU57iA_f71EZGEPQ20RwrGCcjJNAocj5y4fK3bDBsPO9cviU9bkq-V-AmfUwJG01d5gWvxgMlIgrcMsnwTBCuNe83hZ0bbTWY4xwsVnmj3vUSBr7mC37RETSfh1h3cbARlp
orq6H_OCjW57SuQspPfkwPQWpdj2nkNPM9eSTrqreu7w0ksGdiNUC0c6gJ6XSlSLJ-ywter2CyxCFLwj
tDxa2-NczXqZWLqTvy5l4XHePE2yAUH5OcpoAeWGiWvIdya9NvTHZeG8Hl751qZRqYuq0wRdz8YffIO1
vb13Z2CXJbjzcO8__FuPbys_7GVz9y2KszO1AnyQ","x-real-ip":"127.0.0.1","x-real-user-a
gent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0
Safari/537.36","accept":"*/*","content-length":"23","user-agent":"node-fetch/1.0
(+https://github.com/bitinn/node-fetch)","accept-encoding":"gzip,deflate","host"
:"localhost:1050","connection":"close"},"remoteAddress":"127.0.0.1","remotePort"
:50727},"tags":["internal","error"],"err":{"type":"Error","message":"Unable
to retrieve user mobile number. Error: 401 status received","stack":"Error:
Unable to retrieve user mobile number. Error: 401 status received\n    at
/Users/riku/Code/OpenCRVS/opencrvs-core/packages/metrics/src/featur
es/audit/handler.ts:74:11\n at Generator.next (<anonymous>)\n    at
fulfilled (/Users/riku/Code/OpenCRVS/opencrvs-core/packages/metrics/src/featu
res/audit/handler.ts:5:58)\n at runMicrotasks (<anonymous>)\n    at processTicksAndRejections
(node:internal/process/task_queues:96:5)","isBoom":true,"isServer":true,"data":n
ull,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal
Server Error","message":"An internal server error occurred"},"headers":{}}},"msg":
"Unable to retrieve user mobile number. Error: 401 status received"} 

A developer should be expected to see this

@opencrvs/metrics: Error: Unable to retrieve user mobile number. 
  Error: 401 status received
    at /Users/riku/Code/OpenCRVS/opencrvs-core/packages/metrics/src/features/audit/handler.ts:74

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Completed

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions