Better logging

This commit is contained in:
Quentin 2020-01-23 17:08:04 +01:00
parent 2eca18949e
commit 77301e3496
5 changed files with 12 additions and 7 deletions

View file

@ -2,7 +2,7 @@
mkdir -p $5/{log,shared}
cd $5/shared
echo -e 'authenticate ""\nsetevents extended circ circ_minor stream orconn addrmap status_general status_client guard info notice warn err debug newdesc descchanged ns status_server stream_bw clients_seen hs_desc network_liveness' | \
echo -e 'authenticate ""\nsetevents extended circ circ_minor stream orconn addrmap status_general status_client guard info notice warn err newdesc descchanged ns status_server stream_bw clients_seen hs_desc network_liveness' | \
nc --no-shutdown 127.0.0.1 9051 | \
ts \
> ../log/server-tor-events-stdout.log 2> ../log/server-tor-events-stderr.log &

View file

@ -2,7 +2,7 @@
mkdir -p $6/{log,shared}
cd $6/shared
echo -e 'authenticate ""\nsetevents extended circ circ_minor stream orconn addrmap status_general status_client guard info notice warn err debug newdesc descchanged ns status_server stream_bw clients_seen hs_desc network_liveness' | \
echo -e 'authenticate ""\nsetevents extended circ circ_minor stream orconn addrmap status_general status_client guard info notice warn err newdesc descchanged ns status_server stream_bw clients_seen hs_desc network_liveness' | \
nc --no-shutdown 127.0.0.1 9051 | \
ts \
> ../log/server-tor-events-stdout.log 2> ../log/server-tor-events-stderr.log &

View file

@ -54,7 +54,7 @@ socket_create_err:
struct tor_ctl* ugly_global_tctl;
int donar_server_stream_repair(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fd) {
fprintf(stderr, "[%s][donar-server] I am a server, I do nothing with broken streams...\n", current_human_datetime ());
tor_ctl_list_onions(ugly_global_tctl);
/* tor_ctl_list_onions(ugly_global_tctl); */
return 1;
}

View file

@ -2,8 +2,11 @@
void free_fdinfo(void* v) {
struct evt_core_fdinfo* fdinfo = (struct evt_core_fdinfo*)v;
close(fdinfo->fd); // We close the file descriptor here
//fprintf(stderr, "Freeing fdinfo for %s\n", fdinfo->url);
fprintf(stdout, "[%s][evt_core] Freeing fdinfo url=%s fd=%d\n", current_human_datetime (), fdinfo->url, fdinfo->fd);
if (close(fdinfo->fd) != 0) { // We close the file descriptor here
fprintf(stderr, "[%s][evt_core] Failed to close fd for url=%s fd=%d. ", current_human_datetime (), fdinfo->url, fdinfo->fd);
perror("Error");
}
if (fdinfo->free_other != NULL) {
//fprintf(stderr, "Freeing fdinfo->other for %s\n", fdinfo->url);
fdinfo->free_other(fdinfo->other);
@ -274,8 +277,8 @@ void evt_core_loop(struct evt_core_ctx* ctx) {
if (events[n].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) {
int err_fd = events[n].data.fd;
int evt = events[n].events;
if (evt & EPOLLRDHUP) fprintf(stderr, "Epoll Read Hup Event.\n");
if (evt & EPOLLHUP) fprintf(stderr, "Epoll Hup Event.\n");
if (evt & EPOLLRDHUP) fprintf(stderr, "Epoll Read Hup Event fd=%d.\n", err_fd);
if (evt & EPOLLHUP) fprintf(stderr, "Epoll Hup Event fd=%d.\n", err_fd);
if (evt & EPOLLERR) {
int error = 0;
socklen_t errlen = sizeof(error);

View file

@ -31,6 +31,8 @@ int main_on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
sprintf(to_fdinfo.url, "tcp:write:127.0.0.1:%s", port);
evt_core_add_fd (ctx, &to_fdinfo);
printf("[%s][proxy] Accepted a new connection on port=%s: read_fd=%d, write_fd=%d\n", current_human_datetime (), port, conn_sock1, conn_sock2);
return 0;
co_error: