mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-27 19:04:15 +01:00
Updated 'verbose' in 'Platform'
I have changed the logger name from 'str(channel)' to 'str(id(channel))' to create a logger unique to one 'channel'. Also, added a separate method to set verbose output and added a private variable to store the logging handler object
This commit is contained in:
parent
168b98ea7b
commit
2767547019
@ -494,8 +494,9 @@ class Platform(ABC):
|
||||
|
||||
self.session = session
|
||||
self.channel = channel
|
||||
self.logger = logging.getLogger(str(channel))
|
||||
self.logger = logging.getLogger(str(id(channel)))
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
self._verbose_logging_handler = None
|
||||
self.name = "unknown"
|
||||
self._current_user = None
|
||||
|
||||
@ -507,8 +508,8 @@ class Platform(ABC):
|
||||
handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
|
||||
self.logger.addHandler(handler)
|
||||
|
||||
if verbose:
|
||||
self.logger.addHandler(RichHandler())
|
||||
# set the logging verbosity
|
||||
self.set_verbose(verbose)
|
||||
|
||||
base_path = self.PATH_TYPE
|
||||
target = self
|
||||
@ -943,6 +944,24 @@ class Platform(ABC):
|
||||
def unlink(self, target: str):
|
||||
"""Remove a link to a file (similar to `rm`)"""
|
||||
|
||||
def set_verbose(self, verbose: bool):
|
||||
"""Enable or disable verbose output
|
||||
If enabled, commands that are executed by `pwncat`
|
||||
are logged in the output for the user
|
||||
otherwise `pwncat` do not show them"""
|
||||
|
||||
# if `verbose` is `True` and there is no handler for it
|
||||
# then we create one and add it to `self.logger`
|
||||
# otherwise if there is a handler for it
|
||||
# then we remove it and set it to `None`
|
||||
|
||||
if verbose and self._verbose_logging_handler is None:
|
||||
self._verbose_logging_handler = RichHandler()
|
||||
self.logger.addHandler(self._verbose_logging_handler)
|
||||
elif not verbose and self._verbose_logging_handler is not None:
|
||||
self.logger.removeHandler(self._verbose_logging_handler)
|
||||
self._verbose_logging_handler = None
|
||||
|
||||
|
||||
def register(platform: Type[Platform]):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user