Log on stderr

g
This commit is contained in:
Quentin Dufour 2019-04-01 14:40:27 +02:00
parent 5a0e746e30
commit 1e86671fa4

View file

@ -65,7 +65,7 @@ void evt_core_add_cat(struct evt_core_ctx* ctx, struct evt_core_cat* cat) {
}
void evt_core_mv_fd(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct evt_core_cat* to_cat) {
if (ctx->verbose) printf("Moving fd=%d from cat=%s to cat=%s\n",fdinfo->fd, fdinfo->cat->name, to_cat->name);
if (ctx->verbose) fprintf(stderr, "Moving fd=%d from cat=%s to cat=%s\n",fdinfo->fd, fdinfo->cat->name, to_cat->name);
// 1. Update old category
for (int i = 0; i < fdinfo->cat->socklist->len; i++) {
@ -130,7 +130,7 @@ struct evt_core_fdinfo* evt_core_add_fd(struct evt_core_ctx* ctx, struct evt_cor
// 5. Add file descriptor to epoll
add_fd_to_epoll(ctx->epollfd, user_data->fd, cat->flags);
if (ctx->verbose) printf("Added fd=%d with url=%s in cat=%s\n", fdinfo->fd, fdinfo->url, fdinfo->cat->name);
if (ctx->verbose) fprintf(stderr, "Added fd=%d with url=%s in cat=%s\n", fdinfo->fd, fdinfo->url, fdinfo->cat->name);
// 6. Ensure that events arrived before epoll registering are handled
fdinfo->cat->cb(ctx, fdinfo);
@ -145,7 +145,7 @@ struct evt_core_cat* evt_core_rm_fd(struct evt_core_ctx* ctx, int fd) {
struct evt_core_fdinfo* fdinfo = g_hash_table_lookup (ctx->socklist, &fd);
if (fdinfo == NULL) return NULL;
cat = fdinfo->cat;
if (ctx->verbose) printf("Closing fd=%d from cat=%s\n",fdinfo->fd, fdinfo->cat->name);
if (ctx->verbose) fprintf(stderr, "Closing fd=%d from cat=%s\n",fdinfo->fd, fdinfo->cat->name);
// 2. Update category
for (int i = 0; i < cat->socklist->len; i++) {
@ -238,7 +238,7 @@ void evt_core_loop(struct evt_core_ctx* ctx) {
if (ctx->verbose) {
end = clock();
elapsed_in_cb = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("%s cb took %f seconds to execute.\n", fdinfo->url, elapsed_in_cb);
fprintf(stderr, "%s cb took %f seconds to execute.\n", fdinfo->url, elapsed_in_cb);
}
}
}