----- Original Message ----- > When a file transfer starts / finishes an information message is printed (in > INFO log level). > Also INFO messages about the transfer progress are periodically printed. Why info level and not debug? I am not fond adding more code to the "Xfer" code limited by design, I would rather work on shared folder and dnd support. > --- > changes since v4: > - logging is enabled when transferring more files simultaneously > > gtk/channel-main.c | 42 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/gtk/channel-main.c b/gtk/channel-main.c > index 1ad090f..1e0f940 100644 > --- a/gtk/channel-main.c > +++ b/gtk/channel-main.c > @@ -70,6 +70,8 @@ typedef struct SpiceFileXferTask { > char buffer[FILE_XFER_CHUNK_SIZE]; > uint64_t read_bytes; > uint64_t file_size; > + GDateTime *start_time; > + GDateTime *last_update; GDateTime requires glib 2.26 (currently only 2.22 required), you need to make this code conditional. Tbh, I am not sure such information is required in logging, as it can be computed externally differently > GError *error; > } SpiceFileXferTask; > > @@ -1529,15 +1531,31 @@ static void > main_handle_agent_disconnected(SpiceChannel *channel, SpiceMsgIn *in > static void file_xfer_task_free(SpiceFileXferTask *task) > { > SpiceMainChannelPrivate *c; > - > + gchar *basename; > + double seconds; > + GDateTime *now; > g_return_if_fail(task != NULL); > > + if (task->read_bytes == task->file_size) { > + basename = g_file_get_basename(task->file); > + now = g_date_time_new_now_local(); > + seconds = (double) g_date_time_difference(now, task->start_time) / > G_TIME_SPAN_SECOND; > + g_date_time_unref(now); > + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, > + "transferred file %s of %.2f kB size in %.2f seconds (%.2f > MB/s)", > + basename, task->file_size / 1000.0, seconds, > + (double) task->file_size / 1048576 / seconds); > + g_free(basename); > + } > + > c = task->channel->priv; > g_hash_table_remove(c->file_xfer_tasks, GUINT_TO_POINTER(task->id)); > > g_clear_object(&task->channel); > g_clear_object(&task->file); > g_clear_object(&task->file_stream); > + g_date_time_unref(task->start_time); > + g_date_time_unref(task->last_update); > g_free(task); > } > > @@ -1587,6 +1605,9 @@ static void file_xfer_data_flushed_cb(GObject > *source_object, > SpiceFileXferTask *task = user_data; > SpiceMainChannel *channel = (SpiceMainChannel *)source_object; > GError *error = NULL; > + GDateTime *now; > + gchar *basename; > + const GTimeSpan interval = 20 * G_TIME_SPAN_SECOND; > > task->pending = FALSE; > file_xfer_flush_finish(channel, res, &error); > @@ -1595,6 +1616,17 @@ static void file_xfer_data_flushed_cb(GObject > *source_object, > return; > } > > + now = g_date_time_new_now_local(); > + if (interval < g_date_time_difference(now, task->last_update)) { > + g_date_time_unref(task->last_update); > + task->last_update = g_date_time_ref(now); > + basename = g_file_get_basename(task->file); > + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "transferred %.2f%% of the > file %s", > + 100.0 * task->read_bytes / task->file_size, basename); > + g_free(basename); > + } > + g_date_time_unref(now); > + > if (task->progress_callback) > task->progress_callback(task->read_bytes, task->file_size, > task->progress_callback_data); > @@ -2739,6 +2771,7 @@ static void > file_xfer_send_start_msg_async(SpiceMainChannel *channel, > { > SpiceMainChannelPrivate *c = channel->priv; > SpiceFileXferTask *task; > + gchar *basename; > static uint32_t xfer_id; /* Used to identify task id */ > gint i; > > @@ -2753,7 +2786,14 @@ static void > file_xfer_send_start_msg_async(SpiceMainChannel *channel, > task->progress_callback_data = progress_callback_data; > task->callback = callback; > task->user_data = user_data; > + task->start_time = g_date_time_new_now_local(); > + task->last_update = g_date_time_ref(task->start_time); > > + basename = g_file_get_basename(task->file); > + if (basename != NULL) { > + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "transfer of file %s has > started", basename); > + g_free(basename); > + } > CHANNEL_DEBUG(task->channel, "Insert a xfer task:%d to task list", > task->id); > g_hash_table_insert(c->file_xfer_tasks, GUINT_TO_POINTER(task->id), > task); > > -- > 1.9.3 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/spice-devel > _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel