Skip to content

Conversation

H4ppy-04
Copy link
Collaborator

@H4ppy-04 H4ppy-04 commented Apr 9, 2023

About this merge

  • Adding logging module.
  • Logs to file
  • I haven't tested every single log statement but most should work. (will be tested once unit tests are done)

Tasks needed before merge

  • Add relevant files / folder to gitignore
  • unit tests for any logging setup files

H4ppy-04 added 7 commits April 9, 2023 13:34
reformatted /home/josh/projects/Cyber-Breach-Detector/Config/config.py
reformatted /home/josh/projects/Cyber-Breach-Detector/Common/breach_checker.py
reformatted /home/josh/projects/Cyber-Breach-Detector/IP/ip_reputation_checker.py
reformatted /home/josh/projects/Cyber-Breach-Detector/main.py
reformatted /home/josh/projects/Cyber-Breach-Detector/Common/utils.py
reformatted /home/josh/projects/Cyber-Breach-Detector/Email/email_reputation_checker.py
reformatted /home/josh/projects/Cyber-Breach-Detector/Username/username_reputation_checker.py

All done! ✨ 🍰 ✨
7 files reformatted, 4 files left unchanged.
note: previous commit didn't go thru
@initd1 initd1 linked an issue Apr 9, 2023 that may be closed by this pull request
@H4ppy-04 H4ppy-04 requested a review from initd1 April 9, 2023 10:52
@initd1 initd1 linked an issue Apr 9, 2023 that may be closed by this pull request
3 tasks
@H4ppy-04 H4ppy-04 removed the request for review from initd1 April 9, 2023 10:59
@H4ppy-04 H4ppy-04 merged commit a8d59c1 into initd1:feature/logging-module Apr 9, 2023
H4ppy-04

This comment was marked as resolved.

Copy link
Owner

@initd1 initd1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have encountered some issues while executing these changes in my environment. Apart from that there are some minor issues and typos.

I believe this may have preemptively been merged to main. Apologies if I submitted the review. I was thinking you wouldn't be able to merge to main since I have it as a protected branch.

import sys
import time

from colorama import Fore, init
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this package required?

@@ -1,3 +1,4 @@
colorama
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version needed, if really required


# check if the required sections are present
if 'loggers' not in config.sections() or 'handlers' not in config.sections():
raise ValueError('Missing required section in config.ini')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this message would have to be:

raise ValueError('Missing required section in logger.ini')

raise ValueError('Missing required section in config.ini')

if 'keys' not in config['loggers'] or 'suspicious' not in config['loggers']:
raise ValueError('Missing required key in loggers section in config.ini')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar change required:

raise ValueError('Missing required key in loggers section in **logger**.ini')


# check if the required keys are present in the 'handlers' section
if 'keys' not in config['handlers'] or 'console' not in config['handlers']['keys']:
raise ValueError('Missing required key in handlers section in config.ini')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar change required:

raise ValueError('Missing required key in handlers section in **logger**.ini')


# check if the values of the keys are in the expected format
if not isinstance(config.getint('handlers', 'console.level'), int):
raise ValueError('Invalid value for console.level in config.ini')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar change:

raise ValueError('Invalid value for console.level in logger.ini')

raise ValueError('Invalid value for console.level in config.ini')

if not isinstance(config.getint('loggers', 'keys.suspicious.level'), int):
raise ValueError('Invalid value for keys.suspicious.level in config.ini')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar change:

raise ValueError('Invalid value for keys.suspicious.level in logger.ini')

if not os.path.isdir('Logs'):
os.mkdir('Logs')
if not os.path.exists(os.path.join('Logs', 'traceback.log')):
with open(os.path.join('Logs', 'traceback.log')) as fp:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have encountered an issue while running the test when traceback.log file isn't already created. Like in line 10, where Logs directory is created if not exists, we may need to create traceback.log if it doesn't exist.

@initd1
Copy link
Owner

initd1 commented Apr 9, 2023

@GH-Syn The other issue is, when the script is run with the correct API Keys, logs to traceback.log are not being written, and no output is displayed on the terminal. However, no errors during execution.

Might have something to do with the file handler and stream handler.

Example:

$ python main.py -e k@k.cm

$

Don't think a revert of the merge would be recommended, but probably a separate bug issue to resolve these? Let me know your thoughts.

@initd1
Copy link
Owner

initd1 commented Apr 10, 2023

@GH-Syn The other issue is, when the script is run with the correct API Keys, logs to traceback.log are not being written, and no output is displayed on the terminal. However, no errors during execution.

Might have something to do with the file handler and stream handler.

Example:

$ python main.py -e k@k.cm

$

Don't think a revert of the merge would be recommended, but probably a separate bug issue to resolve these? Let me know your thoughts.

Update: I have resolved the issue of stream handler not displaying any output in #31. Will rename the issue and push the update
image

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

Successfully merging this pull request may close these issues.

Integration of logging module debug support with logging.py module
2 participants