A new start

A new start
Because I have been looking for shortcuts to deal with the problem, I have delayed a lot of time, but it is a bit of a harvest.

Recently, I talked with my tutors about many solutions to my project. This time we adopted a conservative strategy.

First try to get the data of the new log message in the journal, and then add them to the model.
Yes, it doesn’t seem to be a difficult problem. Let’s get started.

First gl-journal.c is to process the underlying data.

static gboolean
on_journal_changed (gint fd,
                    GIOCondition condition,
                    GlJournal *self)
{
    gint ret;
    GlJournalEntry *entry;
    GlJournalPrivate *priv = gl_journal_get_instance_private (self);

    ret = sd_journal_process (priv->journal);

switch (ret)
    {
        case SD_JOURNAL_NOP:
            g_debug ("Journal change was a no-op");
            break;
        case SD_JOURNAL_APPEND:
            g_debug ("New journal entries added");
            break;

Then I should add some code here to make it get new log messages. Before that, I found that in gl-journal. c there will be a signal to send a new message, so it must be added after this. Some code to get a new log. Found _gl_query_jouranl_entry(),


static GlJournalEntry *
_gl_journal_query_entry (GlJournal *self);

this function can be used to organize an entry, because the parameters passed are only self, but according to what standard to organize the entry.
after some experiments, it is finally found that the cursor is located according to the current journal. This has led to a very important concept - the cursor.

imaginary sd_journal* journal. The syslog entry can actually imagine that he is a doubly linked list, because it supports (sd_journal_next(journal), sd_journal_previous), so far, an idea is ready to go, Resolve how to respond to updates

But obviously faced with several problems

  1. Cursor_last, how to initialize,
  2. How to add the model after getting the entry, the relevant code for processing the model is defined in gl-journal-model.c.
  3. How to read when reading data, how to use sd_journal_seek_tail() and gl_journal_previous/next() I don’t understand clearly, because I don’t understand the documentation very clearly.

I will try my best to solve this problem in the next time. Go ahead!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值