Skip to content
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

Make Python DB Logger an optional feature #137

Open
rtdtwo opened this issue Apr 27, 2023 · 0 comments
Open

Make Python DB Logger an optional feature #137

rtdtwo opened this issue Apr 27, 2023 · 0 comments

Comments

@rtdtwo
Copy link
Contributor

rtdtwo commented Apr 27, 2023

Problem:

Python DB Logger is a private repository, which makes it not usable by people outside CTS-IT. It also requires setup of MySQL containers on the machine Nacculator is running. This is a major problem if Nacculator is being run by anyone other than the CTS-IT team.

Solution:

Make DB Logger an optional feature by allowing a flag to be passed during runtime that enables or disables Python DB Logger's functionality.

Where can the code be added?

There are ways to implement this, one such way is as follows:

If the flag is set to enable the logs, the DB Logger instance is created as is

db_logger: DBLogger = DBLogger(
logging_instance,
ConnectionHelper(dot_env_file='.env').connect_to_mysql(),
write_to_prod=True
)

But when it is disabled, we can set the instance to None.

Importing the instance will then either be a DBLogger instance or None. To ensure null safety, all DB Logger calls should be wrapped inside an if-else block that checks if the instance is None or not.

A drawback of this method is that it introduces a lot of redundant and dirty-looking extra if-else statements to the code. Hence, a better solution will be incorporate an enable/disable functionality in Python DB Logger itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant