Commit baf1e40d authored by Nils Goroll's avatar Nils Goroll

No need for sprintf in debug output - use VSLb for debug and VSL for init logging

parent 36b4bffc
...@@ -53,17 +53,6 @@ struct vslp_state { ...@@ -53,17 +53,6 @@ struct vslp_state {
const struct vrt_ctx *ctx; const struct vrt_ctx *ctx;
}; };
static void
vlog_debug(const struct vrt_ctx *ctx, char msg[])
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(ctx->vsl);
txt t;
t.b = msg;
t.e = msg + strlen(msg);
VSLbt(ctx->vsl, SLT_Debug, t);
}
static int static int
hostnode_compare(struct vslp_hostnode *a, struct vslp_hostnode *b) hostnode_compare(struct vslp_hostnode *a, struct vslp_hostnode *b)
{ {
...@@ -332,11 +321,10 @@ vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas) ...@@ -332,11 +321,10 @@ vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas)
{ {
for (j = 0; j < replicas; j++) for (j = 0; j < replicas; j++)
{ {
//FIXME can't log due VSLbt in vcl_init VSL(SLT_Debug, 0, "VSLP hashcircle[%5ld] = {point = %8x, host = %2d}\n",
printf("VSLP hashcircle[%5ld] = {point = %8x, host = %2d}\n", i * replicas + j,
i * replicas + j, vslpd->hashcircle[i * replicas + j].point,
vslpd->hashcircle[i * replicas + j].point, vslpd->hashcircle[i * replicas + j].host);
vslpd->hashcircle[i * replicas + j].host);
} }
} }
...@@ -397,6 +385,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui ...@@ -397,6 +385,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
struct vslp_state state; struct vslp_state state;
CHECK_OBJ_NOTNULL(vslpd, VSLPDIR_MAGIC); CHECK_OBJ_NOTNULL(vslpd, VSLPDIR_MAGIC);
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(ctx->vsl);
be_choice = (scalbn(random(), -31) > vslpd->altsrv_p); be_choice = (scalbn(random(), -31) > vslpd->altsrv_p);
...@@ -428,9 +418,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui ...@@ -428,9 +418,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
restarts--; restarts--;
if(restarts <= 0) if(restarts <= 0)
{ {
char msg[56]; VSLb(ctx->vsl, SLT_Debug, "VSLP picked backend %2i for key %8x in restarts: %2i", chosen, hash, restarts_o);
sprintf(msg, "VSLP picked backend %2i for key %8x in restarts: %2i", chosen, hash, restarts_o);
vlog_debug(ctx, msg);
be = vslpd->backend[chosen]; be = vslpd->backend[chosen];
AN(be); AN(be);
return be; return be;
...@@ -454,9 +443,7 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui ...@@ -454,9 +443,7 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
WRONG("VSLP failed to choose a backend"); WRONG("VSLP failed to choose a backend");
be = vslpd->backend[chosen]; be = vslpd->backend[chosen];
} }
char msg[51]; VSLb(ctx->vsl, SLT_Debug, "VSLP picked backend %2i for key %8x in healthy", chosen, hash);
sprintf(msg, "VSLP picked backend %2i for key %8x in healthy", chosen, hash);
vlog_debug(ctx, msg);
} }
else else
{ {
...@@ -465,9 +452,7 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui ...@@ -465,9 +452,7 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
if(chosen < 0) if(chosen < 0)
WRONG("VSLP failed to choose a backend"); WRONG("VSLP failed to choose a backend");
be = vslpd->backend[chosen]; be = vslpd->backend[chosen];
char msg[53]; VSLb(ctx->vsl, SLT_Debug, "VSLP picked backend %2i for key %8x in unhealthy", chosen, hash);
sprintf(msg, "VSLP picked backend %2i for key %8x in unhealthy", chosen, hash);
vlog_debug(ctx, msg);
} }
AN(be); AN(be);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment