mirror of
https://github.com/WCBROW01/zblock.git
synced 2025-12-12 04:28:07 -05:00
[main.c] Add more logging
This commit is contained in:
8
main.c
8
main.c
@ -74,7 +74,7 @@ static void timer_retrieve_feeds(struct discord *client, struct discord_timer *t
|
|||||||
int nfeeds = PQntuples(database_res);
|
int nfeeds = PQntuples(database_res);
|
||||||
zblock_feed_buffer *feed_list = malloc(nfeeds * sizeof(*feed_list));
|
zblock_feed_buffer *feed_list = malloc(nfeeds * sizeof(*feed_list));
|
||||||
if (!feed_list) {
|
if (!feed_list) {
|
||||||
// well there goes that idea
|
log_error("Unable to retrieve feed list: %s", strerror(errno));
|
||||||
PQclear(database_res);
|
PQclear(database_res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,6 +89,7 @@ static void timer_retrieve_feeds(struct discord *client, struct discord_timer *t
|
|||||||
CURLM *multi = curl_multi_init();
|
CURLM *multi = curl_multi_init();
|
||||||
if (!multi) {
|
if (!multi) {
|
||||||
// oh no
|
// oh no
|
||||||
|
log_error("Unable to retrieve feed list: NULL pointer from curl_multi_init()");
|
||||||
goto all_done;
|
goto all_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,6 +372,8 @@ static void on_interaction(struct discord *client, const struct discord_interact
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
int exit_code = 0;
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
struct discord *client = discord_config_init("config.json");
|
struct discord *client = discord_config_init("config.json");
|
||||||
zblock_config_load(client);
|
zblock_config_load(client);
|
||||||
@ -379,6 +382,7 @@ int main(void) {
|
|||||||
database_conn = PQconnectdb(zblock_config.conninfo);
|
database_conn = PQconnectdb(zblock_config.conninfo);
|
||||||
if (!database_conn) {
|
if (!database_conn) {
|
||||||
log_fatal("Failed to connect to database.");
|
log_fatal("Failed to connect to database.");
|
||||||
|
exit_code = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,4 +394,6 @@ int main(void) {
|
|||||||
cleanup:
|
cleanup:
|
||||||
discord_cleanup(client);
|
discord_cleanup(client);
|
||||||
ccord_global_cleanup();
|
ccord_global_cleanup();
|
||||||
|
|
||||||
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user