tsp-devel
[Top][All Lists]
Advanced

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

[Tsp-devel] Re: [bug #22190] SIMPLE_TRACE_FUNC destination redefinition


From: Frederik Deweerdt
Subject: [Tsp-devel] Re: [bug #22190] SIMPLE_TRACE_FUNC destination redefinition
Date: Fri, 1 Feb 2008 10:39:14 +0100

On Feb 1, 2008 9:16 AM, Robert de Vries <address@hidden> wrote:
>
> Follow-up Comment #2, bug #22190 (project tsp):
>
> It is exactly the warning and error messages that end-users are interested in
> when something goes wrong.
>
> In my case the provider failed to register itself with rpcbind due to the
> fact that all twenty (or so) program numbers were already taken. The only
> message that arrived at the user was that the provider failed to start. The
> interesting stuff went to a hidden logfile (about that you should use
> tsp_rpc_cleanup).
>
> My idea is to have a generic function:
> void tsp_trace(int level, const char *src, const char *func, const char *fmt,
> ...)
>
> This function calls internally the default output function unless it is
> overridden by the user by his own function.
> That function would look like this:
> void user_def_trace(int level, const char *src, const char *func, const char
> *fmt, va_list args);
>
That seems OK to me. One thing, if tsp_trace is indeed a macro, this
could remove the need for the src and func arguments. But this
supposes using modern (read non obsolete) compilers, but I'm fine with
it, further, we could use a printk like mecanism to make the "level"
argument optional:

#define DEBUG "<0>"
#define INFO "<1>"
#define WARNING "<2>"
....

#define tsp_trace(x...) __tsp_trace(__FILE__, __LINE__, __FUNCTION__, x)

void __tsp_trace(const char *file, const int line, const char *function, ...)
{
    int default_log_level = 0;
    /* first peek at the first var arg, to see if it is of the form
<0>, <1>, <2>,.... */
    ...
    /* assing the new log level if needed */
    ....
    /* call printf or user_def_trace */
}

Regards,
Frederik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]