When parsing a server configuration line, a global context is set to the
current server instance. This allows to automatically prefix any
warning/error messages by the server name. This prefix is generated via
generate_usermsgs_ctx_str().
The output was not useful for server-template lines as server <id> is
NULL for them. Thus, this patch improves generate_usermsgs_ctx_str() to
identify a server-template. Now, a dedicated 'server-template' prefix is
generated, with <tmpl_info.prefix> used instead of NULL <id> field.
* Example of a previous error message :
[ALERT] (39934) : config : [./hap.cfg:54] : 'server-template be/(null)' : error detected while parsing [...]
* Example of a new error message :
[ALERT] (40205) : config : [./hap.cfg:54] : 'server-template be/local' : error detected while parsing [...]
static void generate_usermsgs_ctx_str(void)
{
struct usermsgs_ctx *ctx = &usermsgs_ctx;
+ struct server *srv;
+ const char *srv_id;
void *area;
int ret;
switch (obj_type(ctx->obj)) {
case OBJ_TYPE_SERVER:
+ srv = __objt_server(ctx->obj);
+ srv_id = srv->id ? srv->id : srv->tmpl_info.prefix;
ret = snprintf(b_tail(&ctx->str), b_room(&ctx->str),
- "'server %s/%s' : ",
- __objt_server(ctx->obj)->proxy->id,
- __objt_server(ctx->obj)->id);
+ "'%s %s/%s' : ",
+ srv->id ? "server" : "server-template",
+ srv->proxy->id, srv_id);
b_add(&ctx->str, MIN(ret, b_room(&ctx->str)));
break;