Skip to content

Commit

Permalink
do all logging on stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
LizzyFleckenstein03 committed Aug 23, 2024
1 parent e67a95d commit 90397d4
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static void on_ToClientAuth(__attribute__((unused)) DragonnetPeer *peer, ToClien
pthread_mutex_lock(&client_auth.mtx);
if (pkt->success) {
client_auth.state = AUTH_SUCCESS;
printf("[access] authenticated successfully\n");
fprintf(stderr, "[access] authenticated successfully\n");
} else {
client_auth.state = AUTH_INIT;
}
Expand Down Expand Up @@ -142,7 +142,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}

printf("[access] connected to %s\n", client->address);
fprintf(stderr, "[access] connected to %s\n", client->address);

client->on_disconnect = &on_disconnect;
client->on_recv = (void *) &on_recv;
Expand Down
2 changes: 1 addition & 1 deletion src/client/client_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void client_auth_run(char *name)
{
pthread_mutex_lock(&client_auth.mtx);

printf("[access] authenticating as %s...\n", name);
fprintf(stderr, "[access] authenticating as %s...\n", name);

dragonnet_peer_send_ToServerAuth(client, &(ToServerAuth) {
.name = name,
Expand Down
2 changes: 1 addition & 1 deletion src/client/client_inventory.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void menu_slot_click(GUIElement *element, bool right)
if (menu.selected) {
InventoryLocation *other = menu.selected->user;

printf("[info] inventory swap (%s %zu) with (%s %zu)\n",
fprintf(stderr, "[info] inventory swap (%s %zu) with (%s %zu)\n",
list_name(loc->list), (size_t) loc->slot, list_name(other->list), (size_t) other->slot);

dragonnet_peer_send_ToServerInventorySwap(client, &(ToServerInventorySwap) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void config_read(const char *path, ConfigEntry *entries, size_t num_entries)
if (!f)
return;

printf("[info] reading config from %s\n", path);
fprintf(stderr, "[info] reading config from %s\n", path);

while (!feof(f)) {
char key[BUFSIZ];
Expand Down
4 changes: 2 additions & 2 deletions src/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv)
fclose(addrfile);
}

printf("[info] listening on %s\n", server->address);
fprintf(stderr, "[info] listening on %s\n", server->address);

server->on_connect = &server_player_add;
server->on_disconnect = &server_player_remove;
Expand All @@ -128,7 +128,7 @@ int main(int argc, char **argv)

flag_slp(&interrupt);

printf("[info] shutting down\n");
fprintf(stderr, "[info] shutting down\n");
dragonnet_listener_close(server);

server_player_deinit();
Expand Down
6 changes: 3 additions & 3 deletions src/server/server_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void server_player_add(DragonnetPeer *peer)
for (size_t i = 0; i < INV_SIZE_MAIN; i++) item_stack_initialize(&player->inventory.main[i]);
pthread_mutex_init(&player->mtx_inv, NULL);

printf("[access] connected %s\n", player->name);
fprintf(stderr, "[access] connected %s\n", player->name);
peer->user = refcount_grb(&player->rc);

// keep the search tree somewhat balanced by using random IDs
Expand Down Expand Up @@ -252,7 +252,7 @@ void server_player_remove(DragonnetPeer *peer)
// map_del returns false if it was canceled
// (we don't want disconnect messages for every player on server shutdown)
if (map_del(&players, &player->id, &cmp_player_id, &refcount_drp, NULL, NULL))
printf("[access] disconnected %s\n", player->name);
fprintf(stderr, "[access] disconnected %s\n", player->name);

if (player->auth && map_del(&players_named, player->name, &cmp_player_name, &refcount_drp, NULL, NULL)) {
pthread_rwlock_rdlock(&player->lock_pos);
Expand Down Expand Up @@ -291,7 +291,7 @@ bool server_player_auth(ServerPlayer *player, char *name)

bool success = map_add(&players_named, player->name, &player->rc, &cmp_player_name, &refcount_inc);

printf("[access] authentication %s: %s -> %s\n", success ? "success" : "failure", old_name, player->name);
fprintf(stderr, "[access] authentication %s: %s -> %s\n", success ? "success" : "failure", old_name, player->name);

// since this is recv thread, we don't need lock_peer
dragonnet_peer_send_ToClientAuth(player->peer, &(ToClientAuth) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/server_terrain.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static void update_percentage()

if (percentage > last_percentage) {
last_percentage = percentage;
printf("[verbose] preparing spawn... %d%%\n", percentage);
fprintf(stderr, "[verbose] preparing spawn... %d%%\n", percentage);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/server/tree_physics.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void tree_physics_check(v3s32 center)
// run depth search
if (!check_tree(root, &positions, &chunks)) {
// a return value of false means a deadlock occured (should be very rare)
printf("[verbose] tree_physics detected deadlock (this not an issue, but should not happen frequently)\n");
fprintf(stderr, "[verbose] tree_physics detected deadlock (this not an issue, but should not happen frequently)\n");

// sleep for 50ms to hopefully resolve the conflict
nanosleep(&(struct timespec) {0, 50e6}, NULL);
Expand Down
2 changes: 1 addition & 1 deletion subprojects/dragonnet.wrap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[wrap-git]
url = https://github.com/dragonblocks/dragonnet
revision = 3b0298c3a99973bdf7836c7df52793293e644bfe
revision = 9cbece535e532204aed752d3e596675e0202c325
clone-recursive = true
depth = 1

0 comments on commit 90397d4

Please sign in to comment.