Skip to content

Commit

Permalink
Documented the update
Browse files Browse the repository at this point in the history
Added a new exception class CombinationException, added new protected fields to _BasicLogger, updated the documentation everywhere, rewrote README.md for the new update.
  • Loading branch information
Nakama3942 committed Apr 5, 2023
1 parent 7ccd5a6 commit f5a1e5c
Show file tree
Hide file tree
Showing 6 changed files with 573 additions and 489 deletions.
356 changes: 193 additions & 163 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion qt_colored_logger/_basic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
# ############################################################################ #

from ._basic_logger import _BasicLogger
from ._exceptions import ColorException
from ._exceptions import ColorException, CombinationException
from ._patterns import _Singleton
53 changes: 37 additions & 16 deletions qt_colored_logger/_basic/_basic_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
"""
Initializes and configures the log.
:param program_name: Installing the program name output
:param time: Setting the time output
:param name: Setting the name output
:param status: Setting the status output
Expand All @@ -49,30 +50,50 @@ def __init__(
self.status_type = status_type
self.message = message
self._ID = random.randint(1000000, 9999999)
self._pc_name = platform.node()
self._user_name = os.getlogin()
self._system_name = platform.system()
self._system_version = platform.version()
self._system_architecture = platform.architecture()
self._pc_machine = platform.machine()

def _initial(self, colors: list[str, str]):
def _initialized_data(self, colors: list[str, str]) -> str:
"""
A method that assemble an entry of system initialized data.
Forms a console string.
:param colors: Color string list of initialized data
:return: a string with initialized data
"""
log = ""
log += f"{colors[1]}"
log += f"{colors[0]}-{self._program_name}?entry> "
log += f"${platform.node()}^{os.getlogin()}"
log += f"@{platform.system()}"
log += f":{platform.version()}"
log += f":{platform.architecture()[0]}"
log += f":{platform.architecture()[1]}"
log += f":{platform.machine()}"
log += f"${self._pc_name}^{self._user_name}"
log += f"@{self._system_name}"
log += f":{self._system_version}"
log += f":{self._system_architecture[0]}"
log += f":{self._system_architecture[1]}"
log += f":{self._pc_machine}"
log += f"{GetAnsiFormat('reset/on')}"
return log

def _html_initial(self, colors: list[str, str]):
def _html_initialized_data(self, colors: list[str, str]) -> str:
"""
A method that assemble an entry of system initialized data.
Forms an HTML string.
:param colors: Color string list of initialized data
:return: a string with initialized data
"""
log = ""
log += f"<span style='background-color: #{colors[1]};'>"
log += f"<span style='color: #{colors[0]};'>-{self._program_name}?entry> "
log += f"${platform.node()}^{os.getlogin()}"
log += f"@{platform.system()}"
log += f":{platform.version()}"
log += f":{platform.architecture()[0]}"
log += f":{platform.architecture()[1]}"
log += f":{platform.machine()}"
log += f"${self._pc_name}^{self._user_name}"
log += f"@{self._system_name}"
log += f":{self._system_version}"
log += f":{self._system_architecture[0]}"
log += f":{self._system_architecture[1]}"
log += f":{self._pc_machine}"
log += f"</span></span>"
return log

Expand All @@ -85,7 +106,7 @@ def _assemble_entry(
bold: bool,
italic: bool,
invert: bool,
):
) -> str:
"""
A method that assemble an entry into a string and returns it.
Forms a console string.
Expand Down Expand Up @@ -121,7 +142,7 @@ def _assemble_html_entry(
message_text: str,
bold: bool,
italic: bool,
):
) -> str:
"""
A method that assemble an entry into a string and returns it.
Forms an HTML string.
Expand Down
13 changes: 13 additions & 0 deletions qt_colored_logger/_basic/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
# ############################################################################ #

class ColorException(BaseException):
"""
The exception that is thrown when there is no color in any palette.
"""
def __init__(self, message):
self.message = message

def __str__(self):
return self.message

class CombinationException(BaseException):
"""
An exception that is used when composing impossible combinations of boolean flags.
"""
def __init__(self, message):
self.message = message

Expand Down
Loading

0 comments on commit f5a1e5c

Please sign in to comment.