From 8020df8e6078e7789d9fec22a678a161f3373476 Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Thu, 24 Oct 2024 15:22:21 -0700 Subject: [PATCH] Logging for thumbnail template management --- cutter/cutter/main.py | 2 ++ restreamer/restreamer/main.py | 2 ++ thrimshim/thrimshim/main.py | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 9de8067..030f589 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -458,6 +458,7 @@ class Cutter(object): image_data = frame elif job.thumbnail_mode == 'TEMPLATE': template, crop, location = get_template(self.dbmanager, job.thumbnail_template, job.thumbnail_crop, job.thumbnail_location) + self.logging.info('Generating thumbnail from the video frame at {} using {} as template'.format(job.thumbnail_time, job.thumbnail_template)) image_data = compose_thumbnail_template(template, frame, crop, location) else: # shouldn't be able to happen given database constraints @@ -771,6 +772,7 @@ class VideoUpdater(object): thumbnail_image = frame elif job.thumbnail_mode == 'TEMPLATE': template, crop, location = get_template(self.dbmanager, job.thumbnail_template, job.thumbnail_crop, job.thumbnail_location) + self.logging.info('Generating thumbnail from the video frame at {} using {} as template'.format(job.thumbnail_time, job.thumbnail_template)) thumbnail_image = compose_thumbnail_template(template, frame, crop, location) else: assert False, "Bad thumbnail mode: {}".format(job.thumbnail_mode) diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index 5a47442..f5173e4 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -503,6 +503,7 @@ def get_thumbnail_named_template(channel, quality): template, crop, location = get_template(app.db_manager, request.args['template'], crop, location) except ValueError: return 'Template {} not found'.format(request.args['template']), 404 + logging.info('Generating thumbnail from the video frame at {} using {} as template'.format(request.args['timestamp'], request.args['template'])) return get_thumbnail(channel, quality, request.args['timestamp'], template, crop, location) @@ -521,6 +522,7 @@ def get_thumbnail_uploaded_template(channel, quality): Should be a comma-seperated list of numbers. """ template = request.data + logging.info('Generating thumbnail from the video frame at {} using a custom template'.format(request.args['timestamp'])) return get_thumbnail(channel, quality, request.args['timestamp'], template, request.args['crop'], request.args['location']) diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index a39b6d5..0e74d83 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -607,6 +607,7 @@ def list_templates(): SELECT name, description, attribution, crop, location FROM templates ORDER BY name """ results = database.query(conn, query) + logging.info('List of thumbnail templates fetched') return json.dumps([row._asdict() for row in results.fetchall()]) @@ -624,6 +625,7 @@ def get_template(name): return 'Template {} not found'.format(name), 404 image = row[0] + logging.info('Thumbnail image of {} fetched'.format(name)) return flask.Response(image, mimetype='image/png') @@ -639,6 +641,7 @@ def get_template_metadata(name): row = results.fetchone() if row is None: return 'Template {} not found'.format(name), 404 + logging.info('Thumbnail metadata of {} fetched'.format(name)) return json.dumps(row._asdict()) def validate_template(new_template): @@ -692,6 +695,7 @@ def add_template(artist=None): ) database.query(conn, query, **new_template) + logging.info('Thumbnail template {} added'.format(new_template['name'])) return '', 201 @app.route('/thrimshim/update-template/', methods=['POST']) @@ -729,6 +733,10 @@ def update_template(name, artist=None): ) for column in columns)) database.query(conn, query, old_name=name, **new_template) + if name == new_template['name']: + logging.info('Thumbnail template {} updated'.format(name)) + else: + logging.info('Thumbnail template {} renamed to {} and updated'.format(name, new_template['name'])) return '', 200 @@ -747,6 +755,7 @@ def get_thumbnail(ident): event = row._asdict() if event['thumbnail_mode'] != 'NONE' and event['thumbnail_image']: + logging.info('Thumbnail for event {} fetched'.format(ident)) return flask.Response(event['thumbnail_image'], mimetype='image/png') else: return '', 404