fix(#10357): prevent DEBUG logs from appearing in production#10376
fix(#10357): prevent DEBUG logs from appearing in production#10376AmirSaudagar55 wants to merge 16 commits intomedic:masterfrom
Conversation
…r55/cht-core into 10357-fix-debug-logs
1yuv
left a comment
There was a problem hiding this comment.
This doesn't fix the underlying problem. If NODE_ENV is not set, which is the not set by default, the environment will be development and still log at debug level. And this will continue print at debug level.
One way would be to consider environment as production when env is not set. This is not a good practice and patchy fix. But there doesn't appear to be any other option until #10356 is fixed.
I'd advise against that approach. @1yuv Quick question: what challenges are you encountering when trying to set |
|
@1yuv @sugat009 Here is another approach which can be consider :
Please let me know if this approach aligns with your expectations or if you’d suggest any refinements. 🙂 |
|
After re-reviewing the current code, I've identified an issue with the default logging level: When the Possible Solution To ensure reliable and configurable logging across all environments, we can implement the following fix:
This approach separates environment optimizations ( #10356 should be addressed separately in another PR with another discussion. Open for further discussion. |
|
Should I Change the documentation too |
yes, that will be necessary, since the current documentation in medic/cht-docs#2030 seems to be referring to |
|
Just updated the documentation. |
|
Hi, I noticed that the some tests are failing with a timeout error. Since this PR changes the default log level to info, those log lines which they are expecting, no longer appear. |
|
@AmirSaudagar55 Thanks for flagging that out. I've rerun the failed jobs, let's see if they pass this time. |
|
The CI workflows seem to have failed again. Looking into this. |
|
@AmirSaudagar55 For the tests that are failing, the Basically, the necessary change is to make sure that the |
|
@AmirSaudagar55 The CI seems to be failing. Can you check it out please? |
|
@sugat009 Yes working on it. I think setting log_level in commands mention in package.json is not effective, CI tests are using docker, so now i will try to add log level to debug in docker environement which is used by those tests specifically and will ensure that it should not be reflected in production environment. |
…integration tests
|
@sugat009 is it fine now? |
|
Thanks for the reminder, @AmirSaudagar55 . The previous builds seem to be failing. I've run the workflows which will run on the latest commit. Let's see. |
sugat009
left a comment
There was a problem hiding this comment.
@AmirSaudagar55 thanks for your work on this.
| containers: | ||
| - env: | ||
| - name: LOG_LEVEL | ||
| value: '{{ .Values.sentinel.log_level | default "info" }}' |
There was a problem hiding this comment.
@AmirSaudagar55 the log_level: "info" needs to be added in the scripts/build/helm/values/base.yaml file as well. Beforehand your changes were passing because sentinel template was trying to access they key from the API service which did not exist and was defaulting to info but I thought the helm template had a typo and I changed the value in the sentinel helm template to use the value from the sentinel itself which is causing the CI to fail.
The changes would look something like this in the scripts/build/helm/values/base.yaml file.
...
# API Service configuration <- Line 7
api:
service:
type: ClusterIP # DEFAULT: Good default for internal services
log_level: "info" # DEFAULT: Log level for API service
# Sentinel Service configuration
sentinel:
log_level: "info" # DEFAULT: Log level for Sentinel service
...|
@AmirSaudagar55 are you planning to continue the work on this PR? Is there any support you need? Please reach out if you get stuck! |
|
Closing. Requested changes done here |
Summary
Fixes #10357 where DEBUG logs appeared in production despite NODE_ENV=production.
Changes
Testing
Production environment (NODE_ENV=production)
Development environment (NODE_ENV=development)
Notes