diff --git a/src/coulobre/local_update.py b/src/coulobre/local_update.py index 4d93d18..503fc3f 100644 --- a/src/coulobre/local_update.py +++ b/src/coulobre/local_update.py @@ -1,5 +1,6 @@ import fcntl import json +import logging import os import shutil import socket @@ -16,6 +17,8 @@ from tempfile import TemporaryDirectory from .release_updates import UpdateError, download_wheel, selected_release +LOGGER = logging.getLogger(__name__) + SOCKET = Path("/run/coulobre-update.sock") STATE = Path("/var/lib/coulobre-update") STATUS = STATE / "status.json" @@ -96,6 +99,14 @@ def publish_status(status, state, message): os.fsync(directory) finally: os.close(directory) + if state != "running": + LOGGER.info( + "Update %s for %s requested by %s. %s", + state, + status.get("target_version"), + status.get("actor"), + message, + ) def display_status(): @@ -453,6 +464,12 @@ def handle_request(peer): "target_version": request["version"], "actor": request["actor"], } + LOGGER.info( + "Update from %s to %s requested by %s.", + installed, + status["target_version"], + status["actor"], + ) try: hostname = check_installation() except UpdateError as error: @@ -465,6 +482,7 @@ def handle_request(peer): def main(): + logging.basicConfig(level=logging.INFO, format="%(message)s") with socket.socket(fileno=0) as peer: try: handle_request(peer)