* @param[in] ci #CONF_ITEM to print file/lineno for.
* @param[in] f_rules Additional optional formatting controls.
* @param[in] fmt of the message.
- * @param[in] ... Message args.
+ * @param[in] ap Message args.
*/
-void _cf_log_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
- fr_log_perror_format_t const *f_rules, char const *fmt, ...)
+void _cf_vlog_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
+ fr_log_perror_format_t const *f_rules, char const *fmt, va_list ap)
{
- va_list ap;
+ va_list aq;
if ((type == L_DBG) && !DEBUG_ENABLED) return;
if (!ci || !ci->filename) {
- va_start(ap, fmt);
- fr_vlog_perror(LOG_DST, type, file, line, f_rules, fmt, ap);
- va_end(ap);
+ va_copy(aq, ap);
+ fr_vlog_perror(LOG_DST, type, file, line, f_rules, fmt, aq);
+ va_end(aq);
return;
}
our_f_rules.subsq_prefix = prefix;
}
- va_start(ap, fmt);
- fr_vlog_perror(LOG_DST, type, file, line, &our_f_rules, fmt, ap);
- va_end(ap);
+ va_copy(aq, ap);
+ fr_vlog_perror(LOG_DST, type, file, line, &our_f_rules, fmt, aq);
+ va_end(aq);
talloc_free(pool);
}
}
+/** Log an error message relating to a #CONF_ITEM
+ *
+ * Drains the fr_strerror() stack emitting one or more error messages.
+ *
+ * @param[in] type of log message.
+ * @param[in] file src file the log message was generated in.
+ * @param[in] line number the log message was generated on.
+ * @param[in] ci #CONF_ITEM to print file/lineno for.
+ * @param[in] f_rules Additional optional formatting controls.
+ * @param[in] fmt of the message.
+ * @param[in] ... Message args.
+ */
+void _cf_log_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
+ fr_log_perror_format_t const *f_rules, char const *fmt, ...)
+{
+ va_list ap;
+
+ if ((type == L_DBG) && !DEBUG_ENABLED) return;
+
+ va_start(ap, fmt);
+ _cf_vlog_perr(type, ci, file, line, f_rules, fmt, ap);
+ va_end(ap);
+}
+
/** Log a debug message relating to a #CONF_ITEM
*
* Always emits a filename/lineno prefix if available
va_end(ap);
}
+
+/** Log an error message in the context of a child pair of the specified parent
+ *
+ * @param[in] parent containing the pair.
+ * @param[in] child name to use as a logging context.
+ * @param[in] type of log message.
+ * @param[in] file src file the log message was generated in.
+ * @param[in] line number the log message was generated on.
+ * @param[in] fmt of the message.
+ * @param[in] ... Message args.
+ */
+void _cf_log_perr_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child,
+ char const *file, int line, fr_log_perror_format_t const *f_rules,
+ char const *fmt, ...)
+{
+ va_list ap;
+ CONF_PAIR const *cp;
+
+ cp = cf_pair_find(parent, child);
+ if (cp) {
+ va_start(ap, fmt);
+ _cf_vlog_perr(type, CF_TO_ITEM(cp), file, line, f_rules, fmt, ap);
+ va_end(ap);
+ return;
+ }
+
+ va_start(ap, fmt);
+ _cf_vlog_perr(type, CF_TO_ITEM(parent), file, line, f_rules, fmt, ap);
+ va_end(ap);
+}
+
/** Print out debugging information about a CONFIG_ITEM
*
* @param[in] ci being debugged.
#define cf_log_perr(_cf, _fmt, ...) _cf_log_perr(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
#define cf_log_pwarn(_cf, _fmt, ...) _cf_log_perr(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
+
+void _cf_vlog_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
+ fr_log_perror_format_t const *f_rules, char const *fmt, va_list ap)
+ CC_HINT(format (printf, 6, 0));
void _cf_log_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
- fr_log_perror_format_t const *f_rules, char const *fmt, ...)
+ fr_log_perror_format_t const *f_rules, char const *fmt, ...)
CC_HINT(format (printf, 6, 7));
#define cf_log_debug_prefix(_cf, _fmt, ...) _cf_log_with_filename(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
*/
#define cf_log_err_by_child(_parent, _child, _fmt, ...) _cf_log_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
+/** Log an error message against a specified child, draining the thread local error stack
+ *
+ * @param[in] _parent CONF_SECTION.
+ * @param[in] _child string identifier.
+ * @param[in] _fmt of message.
+ * @param[in] ... arguments.
+ */
+#define cf_log_perr_by_child(_parent, _child, _f_rules, _fmt, ...) _cf_log_perr_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _f_rules, _fmt, ## __VA_ARGS__)
+
/** Log a warning message against a specified child
*
* @param[in] _parent CONF_SECTION.
void _cf_log_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child,
char const *file, int line, char const *fmt, ...) CC_HINT(format (printf, 6, 7));
+void _cf_log_perr_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child,
+ char const *file, int line, fr_log_perror_format_t const *f_rules,
+ char const *fmt, ...) CC_HINT(format (printf, 7, 8));
+
#define cf_debug(_cf) _cf_debug(CF_TO_ITEM(_cf))
void _cf_debug(CONF_ITEM const *ci);
#ifdef __cplusplus