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

Update logging functionality and improve CSS styles for responsiveness #87

Merged
merged 11 commits into from
Oct 5, 2024

Conversation

ANUKOOL324
Copy link
Contributor

@ANUKOOL324 ANUKOOL324 commented Oct 4, 2024

  1. logger.py:
    • Issue: Redundant file handling when logging messages.
  • Old Code:
  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:
   # 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

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.

  • Solution:
    • Removed unnecessary file close after opening the log file in write mode, utilizing append mode to handle file creation and
      writing efficiently.
  1. style.css:
    • Issues:
      • Inconsistent use of units for margin and padding, affecting responsiveness.
      • 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 ````#noticeTextand replaced it withwhite-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.

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.
Copy link
Owner

@CoolCat467 CoolCat467 left a 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.

@ANUKOOL324
Copy link
Contributor Author

OK i am checking it !

@ANUKOOL324
Copy link
Contributor Author

ANUKOOL324 commented Oct 5, 2024

i am failing in the tests here .. can u help me ? i have applied the changes as per your request ! please assist me here !
i am interested in this project !

@ANUKOOL324
Copy link
Contributor Author

ANUKOOL324 commented Oct 5, 2024

hey @CoolCat467 are u working on it ? do i again PR for my fixes ?

@CoolCat467
Copy link
Owner

There is a type issue, one sec

@ANUKOOL324
Copy link
Contributor Author

Thanks @CoolCat467 ! passed all tests !
check my PR and requested changes !
....merge it under Hacktoberfest 2024 (: ... if any other issue suggest me here !

Copy link
Owner

@CoolCat467 CoolCat467 left a 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!

@CoolCat467 CoolCat467 added the hacktoberfest-accepted Pull requests accepted for hacktoberfest contributions label Oct 5, 2024
@CoolCat467 CoolCat467 merged commit 316ce01 into CoolCat467:main Oct 5, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Pull requests accepted for hacktoberfest contributions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants