diff --git a/asciinema_automation/instruction.py b/asciinema_automation/instruction.py index 56054b0..1744049 100644 --- a/asciinema_automation/instruction.py +++ b/asciinema_automation/instruction.py @@ -2,10 +2,12 @@ import random import time +logger = logging.getLogger(__name__) + class Instruction: def run(self, script): - logging.info(self.__class__.__name__) + logger.info(self.__class__.__name__) class ChangeWaitInstruction(Instruction): @@ -15,7 +17,7 @@ def __init__(self, wait): def run(self, script): super().run(script) - logging.debug("%s->%s", script.wait, self.wait) + logger.debug("%s->%s", script.wait, self.wait) script.wait = self.wait @@ -26,7 +28,7 @@ def __init__(self, delay): def run(self, script): super().run(script) - logging.debug("%s->%s", script.delay, self.delay) + logger.debug("%s->%s", script.delay, self.delay) script.delay = self.delay @@ -38,7 +40,7 @@ def __init__(self, expect_value: str, timeout: int): def run(self, script): super().run(script) - logging.debug("Expect %s", repr(self.expect_value)) + logger.debug("Expect %s", repr(self.expect_value)) script.process.expect(self.expect_value, timeout=self.timeout) @@ -49,7 +51,7 @@ def __init__(self, send_value): def run(self, script): super().run(script) - logging.debug("Send %s", repr(self.send_value)) + logger.debug("Send %s", repr(self.send_value)) self.receive_value = self.send_value # Check for special character @@ -84,7 +86,7 @@ def __init__(self, send_value): def run(self, script): super().run(script) - logging.debug("Send '%s'", self.send_value) + logger.debug("Send '%s'", self.send_value) script.process.send(self.send_value) @@ -94,7 +96,7 @@ def __init__(self, command): def run(self, script): super().run(script) - logging.debug("Send '\\n'") + logger.debug("Send '\\n'") script.process.send("\n") @@ -105,7 +107,7 @@ def __init__(self, control): def run(self, script): super().run(script) - logging.debug("Send ctrl+%s", self.control) + logger.debug("Send ctrl+%s", self.control) script.process.sendcontrol(self.control) @@ -128,7 +130,7 @@ def __init__(self, send, num, enter=False): def run(self, script): super().run(script) - logging.debug("Send %s arrow %i times", self.send, self.num) + logger.debug("Send %s arrow %i times", self.send, self.num) for _ in range(self.num): if script.standart_deviation is None: time.sleep(script.delay) diff --git a/asciinema_automation/script.py b/asciinema_automation/script.py index cbaee13..7e21c98 100644 --- a/asciinema_automation/script.py +++ b/asciinema_automation/script.py @@ -31,6 +31,8 @@ re.UNICODE | re.VERBOSE, ) +logger = logging.getLogger(__name__) + def decode_escapes(s): def decode_match(match): @@ -143,30 +145,30 @@ def execute(self): spawn_command = ( "asciinema rec " + str(self.outputfile) + " " + self.asciinema_arguments ) - logging.info(spawn_command) + logger.info(spawn_command) self.process = pexpect.spawn(spawn_command, logfile=None) self.process.expect("\n") - logging.debug(self.process.before) + logger.debug(self.process.before) if not ( "recording asciicast to " + str(self.outputfile) in str(self.process.before) ): self.process.expect(pexpect.EOF) self.process.close() - logging.debug("Exit status:" + str(self.process.exitstatus)) - logging.debug("Signal status:" + str(self.process.signalstatus)) + logger.debug("Exit status:" + str(self.process.exitstatus)) + logger.debug("Signal status:" + str(self.process.signalstatus)) else: self.process.expect("\n") - logging.debug(self.process.before) - logging.debug(self.process.after) - logging.info("Start reading instructions") + logger.debug(self.process.before) + logger.debug(self.process.after) + logger.info("Start reading instructions") for instruction in self.instructions: time.sleep(self.wait) instruction.run(self) time.sleep(self.wait) - logging.info("Finished reading instructions") + logger.info("Finished reading instructions") self.process.sendcontrol("d") self.process.expect(pexpect.EOF) self.process.close() - logging.debug("Exit status:" + str(self.process.exitstatus)) - logging.debug("Signal status:" + str(self.process.signalstatus)) + logger.debug("Exit status:" + str(self.process.exitstatus)) + logger.debug("Signal status:" + str(self.process.signalstatus))