All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] log: allow for message continuation
Date: Tue, 22 Sep 2020 21:10:29 +0200	[thread overview]
Message-ID: <3bc985d0-302c-2a40-ed86-ca59b4c490ba@gmx.de> (raw)
In-Reply-To: <CAPnjgZ2Yoo7Asa4A8VFCbXLOKi8=8ObE5q4WXExY5uO1cuwyug@mail.gmail.com>

On 9/22/20 8:48 PM, Simon Glass wrote:
> Hi Heinrich,
>
> On Thu, 17 Sep 2020 at 06:19, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> Some drivers use macro pr_cont() for continuing a message sent via printk.
>> Hence if we want to convert printk messaging to using the logging system,
>> we must support continuation of log messages too.
>>
>> As pr_cont() does not provide a message level we need a means of
>> remembering the last log level.
>>
>> With the patch a pseudo log level LOGL_CONT as well as a pseudo log
>> category LOGC_CONT are introduced. Using these results in the application
>> of the same log level and category as in the previous log message.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>>  common/log.c            | 23 ++++++++++++++++++-----
>>  doc/develop/logging.rst |  6 ++++++
>>  include/log.h           |  2 ++
>>  3 files changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/common/log.c b/common/log.c
>> index 9a5f100da3..bafc09f263 100644
>> --- a/common/log.c
>> +++ b/common/log.c
>> @@ -183,10 +183,12 @@ static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec)
>>   * log_dispatch() - Send a log record to all log devices for processing
>>   *
>>   * The log record is sent to each log device in turn, skipping those which have
>> - * filters which block the record
>> + * filters which block the record.
>>   *
>> - * @rec: Log record to dispatch
>> - * @return 0 (meaning success)
>> + * All log messages created while processing log record @rec are ignored.
>> + *
>> + * @rec:       log record to dispatch
>> + * Return:     0 msg sent, 1 msg not sent while already dispatching another msg
>>   */
>>  static int log_dispatch(struct log_rec *rec)
>>  {
>> @@ -199,7 +201,7 @@ static int log_dispatch(struct log_rec *rec)
>>          * as this might result in infinite recursion.
>>          */
>>         if (processing_msg)
>> -               return 0;
>> +               return 1;
>>
>>         /* Emit message */
>>         processing_msg = 1;
>> @@ -214,10 +216,18 @@ static int log_dispatch(struct log_rec *rec)
>>  int _log(enum log_category_t cat, enum log_level_t level, const char *file,
>>          int line, const char *func, const char *fmt, ...)
>>  {
>> +       static enum log_category_t logc_prev = LOGC_NONE;
>> +       static enum log_level_t logl_prev = LOGL_INFO;
>
> I don't think we can use static variables in logging. Perhaps we can
> use gobal_data?

Are you worried about relocation?

The initialization of the global data fields should be done in
log_init() before gd->flags |= GD_FLG_LOG_READY; I assume.

Is the rest ok for you?

Best regards

Heinrich

>
>
>>         char buf[CONFIG_SYS_CBSIZE];
>>         struct log_rec rec;
>>         va_list args;
>>
>> +       /* Check for message continuation */
>> +       if (cat == LOGC_CONT)
>
> Regards,
> Simon
>

  reply	other threads:[~2020-09-22 19:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 12:19 [PATCH 0/2] log: allow for message continuation Heinrich Schuchardt
2020-09-17 12:19 ` [PATCH 1/2] " Heinrich Schuchardt
2020-09-22 18:48   ` Simon Glass
2020-09-22 19:10     ` Heinrich Schuchardt [this message]
2020-09-22 22:03       ` Simon Glass
2020-10-05  1:41         ` Simon Glass
2020-09-17 12:19 ` [PATCH 2/2] test: log: test " Heinrich Schuchardt
2020-09-22 18:48   ` Simon Glass
2020-10-10 21:28   ` Tom Rini
2020-10-10 21:47     ` Sean Anderson
2020-10-10 21:51       ` Tom Rini
2020-10-11  8:09         ` Heinrich Schuchardt
2020-10-11  8:11     ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3bc985d0-302c-2a40-ed86-ca59b4c490ba@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.