1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 07:06:46 +02:00

Refactor logging

- Conference logging now behaves the same as 1-on-1 chats: Instead
  of creating a new log file every time we restat the client
  we use the unique conference ID to keep track of path names.
  This also allows us to load history for saved groups on client startup

- Added a log init function / general code refactor.

- Fixed a bug that caused log files to be created even when logging
  is disabled.
This commit is contained in:
jfreegman
2020-11-17 16:05:20 -05:00
parent c135c812c2
commit 7e1e410307
9 changed files with 351 additions and 148 deletions

View File

@ -434,21 +434,7 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
const char *swch = argv[1];
if (!strcmp(swch, "1") || !strcmp(swch, "on")) {
char myid[TOX_ADDRESS_SIZE];
tox_self_get_address(m, (uint8_t *) myid);
int log_ret = -1;
if (self->type == WINDOW_TYPE_CHAT) {
Friends.list[self->num].logging_on = true;
log_ret = log_enable(self->name, myid, Friends.list[self->num].pub_key, log, LOG_CHAT);
} else if (self->type == WINDOW_TYPE_PROMPT) {
log_ret = log_enable(self->name, myid, NULL, log, LOG_PROMPT);
} else if (self->type == WINDOW_TYPE_CONFERENCE) {
log_ret = log_enable(self->name, myid, NULL, log, LOG_CONFERENCE);
}
msg = log_ret == 0 ? "Logging enabled." : "Warning: Log failed to initialize.";
msg = log_enable(log) == 0 ? "Logging enabled." : "Warning: Failed to enable log.";
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, msg);
return;
} else if (!strcmp(swch, "0") || !strcmp(swch, "off")) {