Re: [PATCH RFC] logger: add support for --loglevel-prefix when logging stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Hi Dennis,

On Mon, May 13, 2013 at 11:57:18PM +0200, Dennis H Jensen wrote:
> This patch adds a new option to logger that will make it look for a
> loglevel prefix <[0-7]> at the beginning of every line.
> 
> If a loglevel is found logger will log the message using the found
> loglevel combined with the facility specified by --priority. When no
> loglevel is found the default level provided by the --priority option
> will be used.

I have doubts if this is a good idea. 

It seems that you're trying to introduce a new meaning of the <n>
convention.  The <n> in the syslog API is not only log level, it's
((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)) -- bottom 3 bits are the
priority and the top 28 bits are the facility). 

It would be better to follow this already existing convention. It means 
to use something like

    --prio-prefix

and use the <n> number as whole priority number. The result will be
command line interface with pretty simple semantic.

The problem is that <n> encoding is not user friendly, but I guess we
should be able to explain all in the logger man page (for example in
an EXAMPLE section). For example user.debug:

    LOG_USER=$((1<<3))
    LOG_DEBUG=7
    echo $(( $LOG_USER & 0x03f8 | $LOG_DEBUG & 0x07 ))

to get the number in shell.

> --- a/misc-utils/logger.c
> +++ b/misc-utils/logger.c
> @@ -64,6 +64,10 @@ enum {
>  	ALL_TYPES = TYPE_UDP | TYPE_TCP
>  };
>  
> +enum {
> +	ARG_LOGLEVEL_PREFIX = 0x100

 We usually use OPT_* and CHAR_MAX, for example:

        OPT_PRIO_PREFIX = CHAR_MAX + 1


    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux