Skip to content

Commit

Permalink
resource: prepend log prefix with resource id to existing log request…
Browse files Browse the repository at this point in the history
… instead of overwriting the prefix
  • Loading branch information
prajnoha committed Dec 6, 2023
1 parent 3a218a3 commit d41ed00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/include/resource/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ int sid_resource_exit_event_loop(sid_resource_t *res);
/*
* logging
*/
void sid_resource_log_output(sid_resource_t *res, log_req_t *log_req, const char *fmt, ...);
void sid_resource_log_output(sid_resource_t *res, const log_req_t *log_req, const char *fmt, ...);

#define SID_RESOURCE_LOG_LINE(res, l, e, ...) \
sid_resource_log_output(res, \
Expand Down
12 changes: 5 additions & 7 deletions src/resource/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,21 +1295,19 @@ int sid_resource_exit_event_loop(sid_resource_t *res)
return sd_event_exit(res->event_loop.sd_event_loop, 0);
}

void sid_resource_log_output(sid_resource_t *res, struct log_req *log_req, const char *fmt, ...)
void sid_resource_log_output(sid_resource_t *res, const log_req_t *log_req, const char *fmt, ...)
{
log_pfx_t *orig_pfx = log_req->pfx;
va_list ap;
log_req_t req;
va_list ap;

if (!res)
return;

log_req->pfx = &((log_pfx_t) {.s = res->id, .n = NULL});
req = (log_req_t) {.pfx = &((log_pfx_t) {.s = res->id, .n = log_req->pfx}), .ctx = log_req->ctx};

va_start(ap, fmt);
service_link_group_vnotify(res->slg, SERVICE_NOTIFICATION_MESSAGE, log_req, fmt, ap);
service_link_group_vnotify(res->slg, SERVICE_NOTIFICATION_MESSAGE, &req, fmt, ap);
va_end(ap);

log_req->pfx = orig_pfx;
}

static void _write_event_source_elem_fields(sid_resource_event_source_t *es,
Expand Down

0 comments on commit d41ed00

Please sign in to comment.