-
Notifications
You must be signed in to change notification settings - Fork 19
Obinna/s3 en 2674 disable logging #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| disable_logging = False | ||
| ): | ||
| if disable_logging: | ||
| sys.stdout = open(os.devnull, "w") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what does this do?
| print(Fore.BLUE + "Exporting spans to Langtrace cloud.." + Fore.RESET) | ||
| provider.add_span_processor(batch_processor_remote) | ||
|
|
||
| sys.stdout = sys.__stdout__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what does this do?
| The result of the export SUCCESS or FAILURE | ||
| """ | ||
| if not self.api_key: | ||
| if not self.api_key and not self.disable_logging: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am thinking a bit about this,
this approach will work fine for now, but it's adding some tech debt to the langtrace and langtrace exporter
i would say a more scalable approach is the following
- make the disable logging as an enviroment variable not an option to be passed
- abstract all Prints with
Foreinto a seperate function inside utils, that recieves 2 arguments which are the message and the color - inside the abstracted method just check for the env variable if it's set then return and do not print other wise print normally
| if not self.api_key and not self.disable_logging: | |
| def log(message, color): | |
| disable_logging = os.environ['DISABLE_LOGGING'] | |
| if disable_logging: | |
| return | |
| print(color, message, FORE.reset) |
what do you think?
Description
Please include a summary of the changes and the related issue to help is review the PR better and faster.
Checklist for adding new integration:
APISin constants folder.SERVICE_PROVIDERSin common.pypatch.pyandinstrumentation.pyfiles.all_instrumentationsin langtrace.py and to theInstrumentationTypein types.py files.