-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update logging functionality and improve CSS styles for responsiveness #87
Conversation
1. **logger.py**: - **Issue**: Redundant file handling when logging messages. - **Old Code**: ```python if not path.exists(log_file): with open(log_file, mode="w", encoding="utf-8") as file: file.close() with open(log_file, mode="a", encoding="utf-8") as file: file.write(f"{log_msg}\n") file.close() **When checking if the log file exists, you opened it in write mode (mode="w"), which would create the file if it didn’t exist.** **However, immediately after that, you closed the file without writing anything to it.** **This is redundant because you don't need to create the file in write mode if you plan to open it again in append mode.** ``` - **New Code**: ```python # Open in append mode; this will create the file if it doesn't exist with open(log_file, mode="a", encoding="utf-8") as file: file.write(f"{log_msg}\n") # This handles both file creation and writing The **with** statement opens the file and ensures it’s properly closed when the block of code is exited, **eliminating the need for the explicit file.close() statement.** ``` - **Solution**: Removed unnecessary file close after opening the log file in write mode, utilizing append mode to handle file creation and writing efficiently. 2. **style.css**: - **Issue**: (1)- Inconsistent use of units for margin and padding, affecting responsiveness. (2)- Deprecated property value `white-space: nowrap;` in `#noticeText`, which can lead to text overflow issues if the text exceeds the container's width. - **Solution**: - Replaced percentage values for margins and paddings with `rem` units for better scalability and consistency across devices. - Removed `white-space: nowrap;` from `#noticeText` and replaced it with `white-space: normal`, allowing text to wrap within the container for improved readability and responsiveness. These changes enhance the logging functionality and improve the CSS styles for better responsiveness and usability across different devices.
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.
One issue, src/sanescansrv/static/style.css
is auto-generated from src/sanescansrv/generate_pages.py
, so you will need to change the code that generates the css instead in this case.
OK i am checking it ! |
i am failing in the tests here .. can u help me ? i have applied the changes as per your request ! please assist me here ! |
hey @CoolCat467 are u working on it ? do i again PR for my fixes ? |
There is a type issue, one sec |
Thanks @CoolCat467 ! passed all tests ! |
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.
Alright, just tested running this with a scanner and it's looking good, thank you so much!
When checking if the log file exists, you opened it in write mode (mode="w"), which would create the file if it didn’t exist. However, immediately after that, you closed the file without writing anything to it.
This is redundant because you don't need to create the file in write mode if you plan to open it again in append mode.
NOTE:- The with statement opens the file and ensures it’s properly closed when the block of code is exited , eliminating
- the need for the explicit
file.close()
statement.writing efficiently.
white-space: nowrap;
in#noticeText
, which can lead to text overflow issues if the textrem
units for better scalability and consistency across devices.white-space: nowrap;
from ````#noticeTextand replaced it with
white-space: normal```, allowing text towrap within the container for improved readability and responsiveness.
These changes enhance the logging functionality and improve the CSS styles for better responsiveness and usability across different devices.