On Tue, Apr 08, 2008 at 02:16:11PM -0500, Dean Luick wrote:
> When running on multiple hosts with output coalesced, it is useful to
> be able to isolate messages from individual processes.  This patch adds
> the ability to add the string "[hostname:pid] " to all messages emitted
> by libhugetlbfs.  Display this additional information by setting the
> environment variable HUGETLB_VERBOSE_ID to anything but "no".
> 
> This change uses a GNU extension of CPP that will eat a preceeding
> comma when using ##__VA_ARGS__ and __VA_ARGS__ is empty.

[snip]
>  static int initialized;
> +static char hostname[64];
> +
> +char *__hugetlbfs_host_info(char *buf, int size)
> +{
> +     if (hostname[0] == 0)   /* empty -- not set */
> +             return "";
> +
> +     snprintf(buf, size, "[%s:%d] ", hostname, getpid());
> +     buf[size-1] = 0;        /* make sure it is null terminated */
> +     return buf;
> +}

Marshalling the prefix into a string buffer like this before printing
it is ugly and unnecessary.  Just printf() the hostname and pid
directly to the log stream.

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to