1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-01 10:46:45 +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

@ -40,7 +40,7 @@ void cmd_conference_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc,
UNUSED_VAR(window);
Tox_Err_Conference_Title err;
char title[MAX_STR_SIZE];
char title[CONFERENCE_MAX_TITLE_LENGTH + 1];
if (argc < 1) {
size_t tlen = tox_conference_get_title_size(m, self->num, &err);
@ -61,15 +61,23 @@ void cmd_conference_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc,
return;
}
size_t len = strlen(argv[1]);
if (len >= sizeof(title)) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to set title: max length exceeded.");
return;
}
snprintf(title, sizeof(title), "%s", argv[1]);
int len = strlen(title);
if (!tox_conference_set_title(m, self->num, (uint8_t *) title, len, &err)) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to set title (error %d)", err);
return;
}
set_window_title(self, title, len);
conference_rename_log_path(m, self->num, title); // must be called first
conference_set_title(self, self->num, title, len);
char timefrmt[TIME_STR_SIZE];
char selfnick[TOX_MAX_NAME_LENGTH];