diff --git a/src/command/commandManager.py b/src/command/commandManager.py index 95a28a1..f460896 100644 --- a/src/command/commandManager.py +++ b/src/command/commandManager.py @@ -2,6 +2,7 @@ from command.impl.addCommand import AddCommand from command.impl.listCommand import ListCommand from command.impl.removeCommand import RemoveCommand from command.impl.restartCommand import RestartCommand +from command.impl.logsCommand import LogsCommand class CommandManager: @@ -12,6 +13,7 @@ class CommandManager: self.addCommand(RemoveCommand()) self.addCommand(ListCommand()) self.addCommand(RestartCommand()) + self.addCommand(LogsCommand()) pass def addCommand(self, command): diff --git a/src/command/impl/logsCommand.py b/src/command/impl/logsCommand.py new file mode 100644 index 0000000..f0c13b5 --- /dev/null +++ b/src/command/impl/logsCommand.py @@ -0,0 +1,10 @@ +from command.command import Command +from traefik.traefikConfig import TraefikConfig +from utils.dockerUtils import getTraefikLogs + +class LogsCommand(Command): + def __init__(self): + super().__init__("logs", "Get traefik logs", "logs") + + def execute(self, traefikConfig: TraefikConfig, args): + getTraefikLogs() \ No newline at end of file diff --git a/src/utils/dockerUtils.py b/src/utils/dockerUtils.py index eba1874..5a1d197 100644 --- a/src/utils/dockerUtils.py +++ b/src/utils/dockerUtils.py @@ -16,3 +16,7 @@ def restartTraefik(): subprocess.run(["docker", "restart", containerName]) print("Done!") + +def getTraefikLogs(): + print("Getting Traefik logs, please wait...") + subprocess.run(["docker", "logs", containerName, "-f"]) \ No newline at end of file