-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add clear_logs utility function
This commit adds a new utility function, `clear_logs()`, that clears the contents of the `logs.log` file on startup. The function is implemented in the `clear_logs.py` file located in the `app/utils` directory. This utility is necessary to ensure that the log file starts with a clean slate each time the application is launched. - The `clear_logs()` function deletes the contents of the `logs.log` file using the `w` mode of the `open()` function. - The function is called in the application's initialization file, `__init__.py`, alongside other startup tasks. - The commit also includes changes to the `.gitignore` file to include `swagger.json` and updates the version number in the `package.json` file to `3.0.4`. Note: The `compile_swagger()` function in the `compile_swagger.py` file is commented out for now, as its implementation is no longer needed.
- Loading branch information
1 parent
5ed7d06
commit 55a1374
Showing
8 changed files
with
24 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from flask_restx import Api | ||
from json import dumps | ||
from os import path | ||
|
||
def clear_logs(): | ||
"""Clear the logs.log file on startup""" | ||
base_dir = path.dirname(path.dirname(path.dirname(path.abspath(__file__)))) | ||
|
||
# Clear log file contents on startup | ||
if path.exists(path.join(base_dir, "../", "database", "logs.log")): | ||
with open(path.join(base_dir, "../", "database", "logs.log"), "w", encoding="utf-8") as f: | ||
f.write("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.