Enable calling clicon_err_fn with fn=NULL
This commit is contained in:
parent
aaa18897ef
commit
f9eacebf68
1 changed files with 36 additions and 18 deletions
|
|
@ -239,30 +239,48 @@ clicon_err_fn(const char *fn,
|
||||||
if (cec->cec_logfn(cec->cec_handle, suberr, cb) < 0)
|
if (cec->cec_logfn(cec->cec_handle, suberr, cb) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Here we could take care of specific errno, like application-defined errors */
|
/* Here we could take care of specific errno, like application-defined errors */
|
||||||
|
if (fn)
|
||||||
clicon_log(LOG_ERR, "%s: %d: %s: %s: %s",
|
clicon_log(LOG_ERR, "%s: %d: %s: %s: %s",
|
||||||
fn,
|
fn,
|
||||||
line,
|
line,
|
||||||
clicon_strerror(category),
|
clicon_strerror(category),
|
||||||
cbuf_get(cb),
|
cbuf_get(cb),
|
||||||
msg);
|
msg);
|
||||||
|
else
|
||||||
|
clicon_log(LOG_ERR, "%s: %s: %s",
|
||||||
|
clicon_strerror(category),
|
||||||
|
cbuf_get(cb),
|
||||||
|
msg);
|
||||||
if (cb)
|
if (cb)
|
||||||
cbuf_free(cb);
|
cbuf_free(cb);
|
||||||
}
|
}
|
||||||
else if (suberr){ /* Actually log it */
|
else if (suberr){ /* Actually log it */
|
||||||
/* Here we could take care of specific errno, like application-defined errors */
|
/* Here we could take care of specific errno, like application-defined errors */
|
||||||
|
if (fn)
|
||||||
clicon_log(LOG_ERR, "%s: %d: %s: %s: %s",
|
clicon_log(LOG_ERR, "%s: %d: %s: %s: %s",
|
||||||
fn,
|
fn,
|
||||||
line,
|
line,
|
||||||
clicon_strerror(category),
|
clicon_strerror(category),
|
||||||
msg,
|
msg,
|
||||||
suberr==XMLPARSE_ERRNO?"XML parse error":strerror(suberr));
|
suberr==XMLPARSE_ERRNO?"XML parse error":strerror(suberr));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
clicon_log(LOG_ERR, "%s: %s: %s",
|
||||||
|
clicon_strerror(category),
|
||||||
|
msg,
|
||||||
|
suberr==XMLPARSE_ERRNO?"XML parse error":strerror(suberr));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (fn)
|
||||||
clicon_log(LOG_ERR, "%s: %d: %s: %s",
|
clicon_log(LOG_ERR, "%s: %d: %s: %s",
|
||||||
fn,
|
fn,
|
||||||
line,
|
line,
|
||||||
clicon_strerror(category),
|
clicon_strerror(category),
|
||||||
msg);
|
msg);
|
||||||
|
else
|
||||||
|
clicon_log(LOG_ERR, "%s: %s",
|
||||||
|
clicon_strerror(category),
|
||||||
|
msg);
|
||||||
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (msg)
|
if (msg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue