* @todo - check that the stack is at frame 0, otherwise
* more things have gone wrong.
*/
- fr_assert_msg(request_is_internal(request) || request_is_detached(request) || (request->log.unlang_indent == 0),
- "Request %s bad log indentation - expected 0 got %u", request->name, request->log.unlang_indent);
+ fr_assert_msg(request_is_internal(request) || request_is_detached(request) || (request->log.indent.unlang == 0),
+ "Request %s bad log indentation - expected 0 got %u", request->name, request->log.indent.unlang);
fr_assert_msg(!unlang_interpret_is_resumable(request),
"Request %s is marked as yielded at end of processing", request->name);
fr_assert_msg(unlang_interpret_stack_depth(request) == 0,
/*
* Make sure the indent isn't set to something crazy
*/
- unlang_indent = request->log.unlang_indent > sizeof(spaces) - 1 ?
+ unlang_indent = request->log.indent.unlang > sizeof(spaces) - 1 ?
sizeof(spaces) - 1 :
- request->log.unlang_indent;
+ request->log.indent.unlang;
- module_indent = request->log.module_indent > sizeof(spaces) - 1 ?
+ module_indent = request->log.indent.module > sizeof(spaces) - 1 ?
sizeof(spaces) - 1 :
- request->log.module_indent;
+ request->log.indent.module;
/*
* Module name and indentation i.e.
ssize_t marker_idx, char const *marker_fmt, ...)
{
char const *ellipses = "";
- uint8_t unlang_indent;
- uint8_t module_indent;
+ rindent_t indent;
va_list ap;
char *error;
static char const marker_spaces[] = " "; /* 60 */
/*
* Don't want format markers being indented
*/
- unlang_indent = request->log.unlang_indent;
- module_indent = request->log.module_indent;
- request->log.unlang_indent = 0;
- request->log.module_indent = 0;
+ indent = request->log.indent;
+ request->log.indent.module = 0;
+ request->log.indent.unlang = 0;
va_start(ap, marker_fmt);
error = fr_vasprintf(request, marker_fmt, ap);
log_request(type, lvl, request, file, line, "%s%.*s^ %s", ellipses, (int) marker_idx, marker_spaces, error);
talloc_free(error);
- request->log.unlang_indent = unlang_indent;
- request->log.module_indent = module_indent;
+ request->log.indent = indent;
}
void log_request_hex(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request,
*
*/
typedef struct log_dst log_dst_t;
+typedef struct rindent_s {
+ uint8_t unlang; //!< By how much to indent log messages. uin8_t so it's obvious
+ //!< when a request has been exdented too much.
+ uint8_t module; //!< Indentation after the module prefix name.
+} rindent_t;
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/util/log.h>
#define RPEDEBUG4(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
/** @} */
-typedef struct {
- uint8_t unlang_indent; //!< By how much to indent log messages. uin8_t so it's obvious
- //!< when a request has been exdented too much.
- uint8_t module_indent; //!< Indentation after the module prefix name.
-} rindent_t;
-
/** Save indentation for later restoral.
*
* This call avoids the need to manually REXDENT on error paths. We
*
*/
#define RINDENT_SAVE(_x, _request) do { \
- (_x)->unlang_indent = request->log.unlang_indent; \
- (_x)->module_indent = request->log.module_indent; \
+ (_x)->indent = request->log.indent; \
} while (0)
#define RINDENT_RESTORE(_request, _x) do { \
- request->log.unlang_indent = (_x)->unlang_indent; \
- request->log.module_indent = (_x)->module_indent; \
+ request->log.indent = (_x)->indent; \
} while (0)
#ifdef DEBUG_INDENT
*/
# define RINDENT() do {\
if (request->module) {\
- request->log.module_indent += 2;\
+ request->log.indent.unlang += 2;\
} else {\
- request->log.unlang_indent += 2;\
+ request->log.indent.unlang += 2;\
}\
} while(0)
*/
# define REXDENT() do {\
if (request->module) {\
- request->log.module_indent -= 2;\
+ request->log.indent.unlang -= 2;\
} else {\
- request->log.unlang_indent -= 2;\
+ request->log.indent.unlang -= 2;\
}\
} while(0)
#endif
* Copy debug information.
*/
memcpy(&(child->log), &(parent->log), sizeof(child->log));
- child->log.unlang_indent = 0; /* Apart from the indent which we reset */
- child->log.module_indent = 0; /* Apart from the indent which we reset */
+ child->log.indent.unlang = 0; /* Apart from the indent which we reset */
+ child->log.indent.module = 0; /* Apart from the indent which we reset */
child->log.lvl = parent->log.lvl;
}
fr_log_lvl_t lvl; //!< Log messages with lvl >= to this should be logged.
- uint8_t unlang_indent; //!< By how much to indent log messages. uin8_t so it's obvious
- //!< when a request has been exdented too much.
- uint8_t module_indent; //!< Indentation after the module prefix name.
+ rindent_t indent; //!< Indentation for log messages.
} log;
char const *component; //!< Section the request is in.
rcode = state->current->func(request, state, state->current);
if (rcode < 0) {
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
/*
* Expansions, etc. failures are SOFT failures, which undo the edit
/*
* Save current indentation for the error path.
*/
- RINDENT_SAVE(&state->indent, request);
+ RINDENT_SAVE(state, request);
}
/** Execute an update block
if (!vp) {
*p_result = frame->result;
#ifndef NDEBUG
- fr_assert(state->indent == request->log.unlang_indent);
+ fr_assert(state->indent == request->log.indent.unlang);
#endif
return UNLANG_ACTION_CALCULATE_RESULT;
}
state->request = request;
state->depth = depth;
#ifndef NDEBUG
- state->indent = request->log.unlang_indent;
+ state->indent = request->log.indent.unlang;
#endif
/*
intp = stack->intp;
intp->funcs.stop(request, intp->uctx);
- request->log.unlang_indent = 0; /* nothing unwinds the indentation stack */
+ request->log.indent.unlang = 0; /* nothing unwinds the indentation stack */
request->master_state = REQUEST_STOP_PROCESSING;
}
* @todo - check that the stack is at frame 0, otherwise
* more things have gone wrong.
*/
- fr_assert_msg(request->parent || (request->log.unlang_indent == 0),
- "Request %s bad log indentation - expected 0 got %u", request->name, request->log.unlang_indent);
+ fr_assert_msg(request->parent || (request->log.indent.unlang == 0),
+ "Request %s bad log indentation - expected 0 got %u", request->name, request->log.indent.unlang);
fr_assert_msg(!unlang_interpret_is_resumable(request),
"Request %s is marked as yielded at end of processing", request->name);
}
/*
* Push the child, and set it's top frame to be true.
*/
- child->log.unlang_indent = parent->log.unlang_indent;
+ child->log.indent.unlang = parent->log.indent.unlang;
/*
* Initialize some basic information for the child.
rlm_rcode_t rcode = state-> set_rcode ? state->rcode : *p_result;
#ifndef NDEBUG
- fr_assert(state->unlang_indent == request->log.unlang_indent);
+ fr_assert(state->unlang_indent == request->log.indent.unlang);
#endif
fr_assert(rcode >= RLM_MODULE_REJECT);
state->previous_module = request->module;
#ifndef NDEBUG
- state->unlang_indent = request->log.unlang_indent;
+ state->unlang_indent = request->log.indent.unlang;
#endif
/*
* Process a stand-alone child, and fall through
unlang_frame_state_timeout_t *state = talloc_get_type_abort(frame->state, unlang_frame_state_timeout_t);
if (!state->success) {
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
RWDEBUG("Timeout exceeded");
return UNLANG_ACTION_FAIL;
/*
* Save current indentation for the error path.
*/
- RINDENT_SAVE(&state->indent, request);
+ RINDENT_SAVE(state, request);
timeout = fr_time_add(fr_time(), state->timeout);
xlat_action_t xa;
xlat_exp_head_t const *child = NULL;
- RINDENT_SAVE(&state->indent, request);
+ RINDENT_SAVE(state, request);
RINDENT();
xa = xlat_frame_eval(state->ctx, &state->values, &child, request, state->head, &state->exp);
fr_value_box_list_talloc_free(&state->out);
if (unlang_xlat_push(state->ctx, state->success, &state->out, request, child, false) < 0) {
*p_result = RLM_MODULE_FAIL;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_STOP_PROCESSING;
}
return UNLANG_ACTION_PUSHED_CHILD;
case XLAT_ACTION_DONE:
if (state->success) *state->success = true;
*p_result = RLM_MODULE_OK;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
case XLAT_ACTION_FAIL:
fail:
if (state->success) *state->success = false;
*p_result = RLM_MODULE_FAIL;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
default:
case XLAT_ACTION_DONE:
if (state->success) *state->success = true;
*p_result = RLM_MODULE_OK;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
case XLAT_ACTION_PUSH_UNLANG:
fr_value_box_list_talloc_free(&state->out);
if (unlang_xlat_push(state->ctx, state->success, &state->out, request, child, false) < 0) {
*p_result = RLM_MODULE_FAIL;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_STOP_PROCESSING;
}
return UNLANG_ACTION_PUSHED_CHILD;
case XLAT_ACTION_FAIL:
if (state->success) *state->success = false;
*p_result = RLM_MODULE_FAIL;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
/* DON'T SET DEFAULT */
}
fr_assert(0); /* Garbage xlat action */
*p_result = RLM_MODULE_FAIL;
- RINDENT_RESTORE(request, &state->indent);
+ RINDENT_RESTORE(request, state);
return UNLANG_ACTION_CALCULATE_RESULT;
}