Skip to content

Commit

Permalink
Refactor logging and main function in HiddenEye
Browse files Browse the repository at this point in the history
The main function in hiddeneye.py file has been refactored for a more efficient logging process. The module imports have been improved, while the constant messages have been moved to the top. A new helper function `log_info_multiple_messages()` has been introduced to ease the logging of multiple messages. The main execution function has been renamed to `run_app()`.
  • Loading branch information
sTiKyt committed Feb 15, 2024
1 parent 58f1771 commit 4981b27
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions hiddeneye_reborn/hiddeneye.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
#!/usr/bin/env python
from hiddeneye_reborn.logs.default_logging import logging, log, set_logging_config
from hiddeneye_reborn.core.text_interface.main import args
from hiddeneye_reborn.network.verification import verify_connection
from .logs.default_logging import logging, log, configure_logging
from .core.text_interface.main import args
from .network.verification import verify_connection

from rich.traceback import install

LOGGING_LEVEL = logging.DEBUG
SUCCESS_MESSAGE = "Success, you can access this via terminal!"
WARNING_MESSAGE = "THIS IS NOT PRODUCTION READY, STOP MAKING USELESS ISSUES PLEASE"


def initialize_app():
install(show_locals=True, width=148)


def main():
set_logging_config(level=LOGGING_LEVEL)
log.info("Success, you can access this via terminal!")
log.info("THIS IS NOT PRODUCTION READY, STOP MAKING USELESS ISSUES PLEASE")
def configure_and_log_app():
configure_logging(level=LOGGING_LEVEL)
log_info_multiple_messages([SUCCESS_MESSAGE, WARNING_MESSAGE])
log.debug("Logging level set to %s", LOGGING_LEVEL)
verify_connection()
log.debug("Non-interactive mode set to %s", args.non_interactive)


def execute():
def log_info_multiple_messages(messages):
for message in messages:
log.info(message)


def run_app():
initialize_app()
main()
configure_and_log_app()


if __name__ == "__main__":
run_app()

0 comments on commit 4981b27

Please sign in to comment.