From: Sascha Hauer <s.hauer@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v1 1/2] commands: dmesg: add print raw parameter
Date: Mon, 25 Feb 2019 09:10:17 +0100 [thread overview]
Message-ID: <20190225081017.hfvcadgmn6k5nyjn@pengutronix.de> (raw)
In-Reply-To: <20190221132603.21201-1-o.rempel@pengutronix.de>
On Thu, Feb 21, 2019 at 02:26:02PM +0100, Oleksij Rempel wrote:
> Add -r option to mimic functionality of linux dmesg.
> It will prefix log level and timestamp to each buffer:
> <6>[ 460us] barebox 2019.02.0-00266-g6aea757067-dirty #355 Thu Feb 21 11:51:43 CET 2019
> <6>[ 6279us] Board: DPTechnics DPT-Module
> <6>[ 209281us] mdio_bus: miibus0: probed
> <6>[ 210184us] ag71xx-gmac 18070000.mac@19000000.of: network device registered
> <6>[ 216051us] m25p80 w25q128@00: w25q128 (16384 Kbytes)
> <6>[ 219913us] netconsole: registered as netconsole-1
> <6>[ 223312us] malloc space: 0x80c00000 -> 0x80ffffff (size 4 MiB)
> <6>[ 228255us] eth0: got preset MAC address: c4:93:00:00:ae:89
> <6>[ 246363us] running /env/bin/init...
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
Applied, thanks
Sascha
> commands/dmesg.c | 8 ++++++--
> common/console_common.c | 3 +++
> include/printk.h | 1 +
> 3 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/commands/dmesg.c b/commands/dmesg.c
> index 510bc16594..5c2728581d 100644
> --- a/commands/dmesg.c
> +++ b/commands/dmesg.c
> @@ -30,7 +30,7 @@ static int do_dmesg(int argc, char *argv[])
> int delete_buf = 0, emit = 0;
> unsigned flags = 0;
>
> - while ((opt = getopt(argc, argv, "ctde")) > 0) {
> + while ((opt = getopt(argc, argv, "ctder")) > 0) {
> switch (opt) {
> case 'c':
> delete_buf = 1;
> @@ -44,6 +44,9 @@ static int do_dmesg(int argc, char *argv[])
> case 'e':
> emit = 1;
> break;
> + case 'r':
> + flags |= BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME;
> + break;
> default:
> return COMMAND_ERROR_USAGE;
> }
> @@ -88,13 +91,14 @@ BAREBOX_CMD_HELP_TEXT("Options:")
> BAREBOX_CMD_HELP_OPT ("-c", "Delete messages after printing them")
> BAREBOX_CMD_HELP_OPT ("-d", "Show a time delta to the last message")
> BAREBOX_CMD_HELP_OPT ("-e <msg>", "Emit a log message")
> +BAREBOX_CMD_HELP_OPT ("-r", "Print timestamp and log-level prefixes.")
> BAREBOX_CMD_HELP_OPT ("-t", "Show timestamp informations")
> BAREBOX_CMD_HELP_END
>
> BAREBOX_CMD_START(dmesg)
> .cmd = do_dmesg,
> BAREBOX_CMD_DESC("Print or control log messages")
> - BAREBOX_CMD_OPTS("[-cdet]")
> + BAREBOX_CMD_OPTS("[-cdert]")
> BAREBOX_CMD_GROUP(CMD_GRP_INFO)
> BAREBOX_CMD_HELP(cmd_dmesg_help)
> BAREBOX_CMD_END
> diff --git a/common/console_common.c b/common/console_common.c
> index 0131a1190a..bc3a305b27 100644
> --- a/common/console_common.c
> +++ b/common/console_common.c
> @@ -202,6 +202,9 @@ void log_print(unsigned flags)
> uint64_t diff = log->timestamp - time_beginning;
> unsigned long difful;
>
> + if (flags & (BAREBOX_LOG_PRINT_RAW))
> + printf("<%i>", log->level);
> +
> do_div(diff, 1000);
> difful = diff;
>
> diff --git a/include/printk.h b/include/printk.h
> index ab2c64cf3c..64205b2880 100644
> --- a/include/printk.h
> +++ b/include/printk.h
> @@ -136,6 +136,7 @@ extern void log_clean(unsigned int limit);
>
> #define BAREBOX_LOG_PRINT_TIME (1 << 0)
> #define BAREBOX_LOG_DIFF_TIME (1 << 1)
> +#define BAREBOX_LOG_PRINT_RAW (1 << 2)
>
> void log_print(unsigned flags);
>
> --
> 2.20.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2019-02-25 8:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 13:26 Oleksij Rempel
2019-02-21 13:26 ` [PATCH v1 2/2] commands: dmesg: add -l option to restrict output level Oleksij Rempel
2019-02-25 8:10 ` Sascha Hauer [this message]
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=20190225081017.hfvcadgmn6k5nyjn@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=o.rempel@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox