After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 753471 - Update the event list when new events are logged
Update the event list when new events are logged
Status: RESOLVED OBSOLETE
Product: gnome-logs
Classification: Other
Component: general
git master
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-logs maintainer(s)
gnome-logs maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-08-10 14:21 UTC by David King
Modified: 2018-05-22 13:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (9.29 KB, patch)
2015-12-10 07:07 UTC, Jonathan Kang
needs-work Details | Review
patch updated (6.09 KB, patch)
2016-01-05 13:00 UTC, Jonathan Kang
none Details | Review
patch updated (5.00 KB, patch)
2016-01-13 14:03 UTC, Jonathan Kang
none Details | Review
Add a refresh button (8.30 KB, patch)
2016-12-17 14:10 UTC, Jonathan Kang
rejected Details | Review

Description David King 2015-08-10 14:21:25 UTC
The journal provides sd_journal_get_fd() to give a file descriptor which notifies clients of updates, and this should be used to display new log messages as they are pushed into the journal.
Comment 1 Jonathan Kang 2015-12-10 07:07:20 UTC
Created attachment 317090 [details] [review]
Patch
Comment 2 David King 2016-01-04 15:05:04 UTC
Review of attachment 317090 [details] [review]:

It seems odd to move the code for monitoring the journal from out of gl-journal.c to gl-journal-model.c. The abstraction for pretty much everything journal-related should stay in gl-journal.c, and only the GListModel parts should be in gl-journal-model.c.

The better way to handle this is to do the monitoring in GlJournal, and to emit a signal when the journal has changed. You could build up a queue of new log items, which GlJournalModel pushes into the model, adding new API in GlJournal to fetch the new items. That way, the journal state is also kept in GlJournal, and does not have to be driven from the outside. Alternatively, you could set the journal read pointer to the end of the journal (and keep track of the number of new entries), and run the iterations in GlJournalModel. Another possibility is to emit an "entry-added" signal for each entry that is created, which has the GlJournalEntry as part of the signal emission, and to process each one in turn in GlJournalModel.

These approaches should hopefully reduce the amount of new GlJournal API that would be needed, and simplify the model code.
Comment 3 Jonathan Kang 2016-01-05 13:00:40 UTC
Created attachment 318253 [details] [review]
patch updated

Monitor journal changes in GlJournal, and emit signal "entries_added" to notify GlJournalModel for updating the event list.
Comment 4 David King 2016-01-05 14:54:25 UTC
Review of attachment 318253 [details] [review]:

You shouldn't need to add the _skip() API in GlJournal for this. Simply return the new GlJournalEntry as part of the (entry-added) signal emission, and add it to GlJournalModel as part of handling the signal.
Comment 5 Jonathan Kang 2016-01-05 15:14:06 UTC
Well, I found that multiple entries could be added at the same time, but only emit the signal once. The reason why I add _skip() API to GlJournal is to separate fetching old entries in batches and fetching new entries. Both need operations on the read pointer of journal.
Comment 6 David King 2016-01-05 15:19:48 UTC
(In reply to Jonathan Kang from comment #5)
> Well, I found that multiple entries could be added at the same time, but
> only emit the signal once.

Emit the signal once per entry, possibly in an idle handler.

> The reason why I add _skip() API to GlJournal is
> to separate fetching old entries in batches and fetching new entries. Both
> need operations on the read pointer of journal.

You do not need access to the read pointer if you return the entry as part of the signal.
Comment 7 Jonathan Kang 2016-01-13 14:03:35 UTC
Created attachment 318962 [details] [review]
patch updated
Comment 8 David King 2016-01-13 14:18:24 UTC
Review of attachment 318962 [details] [review]:

::: src/gl-journal.c
@@ +242,2 @@
     gint ret;
+    GlJournalEntry *entry;

You should move this into the more-specific block for the do-while loop. The gint r should probably move to a more-specific block too.

@@ +326,3 @@
     gobject_class->finalize = gl_journal_finalize;
+
+    entries_signal = g_signal_new ("entries_added", G_OBJECT_CLASS_TYPE (klass),

It's better to use the canonical name for the signal here, by replacing the underscore with a dash. Also, as a single GlJournalEntry is associated with the signal emission, the name should be "entry-added".

@@ +357,3 @@
     }
 
+    priv->shown_entries = 0;

The private structure is zero-initialized, so there is no need to do so again.

@@ +686,3 @@
         return NULL;
 
+    priv->shown_entries++;

The journal should not have any knowledge of the number of entries in the GlJournal Model, so you need to find some other way of keeping track of this.
Comment 9 Jonathan Kang 2016-12-17 14:10:44 UTC
Created attachment 342120 [details] [review]
Add a refresh button

Add a refresh button so that users can refresh the log list and view the latest log.
Comment 10 David King 2017-05-09 09:38:15 UTC
Review of attachment 342120 [details] [review]:

There should not be a refresh button - this should be automatic on notification of new events from the journal.
Comment 11 GNOME Infrastructure Team 2018-05-22 13:05:12 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-logs/issues/9.