Add option for automatic logging (#203)
Just so we're on the same page, this is enabled by default. Co-authored-by: Cents02 <Cents02@Cents0.me>
This commit is contained in:
parent
bab10ea14d
commit
36b5af3cb9
@ -427,6 +427,9 @@ public:
|
||||
// Get the message for the CM for casing alerts.
|
||||
QString get_casing_can_host_cases();
|
||||
|
||||
// Get if automatic logging is enabled
|
||||
bool get_auto_logging_enabled();
|
||||
|
||||
// The file name of the log file in base/logs.
|
||||
QString log_filename;
|
||||
|
||||
|
@ -131,6 +131,8 @@ private:
|
||||
QCheckBox *ui_casing_cm_cb;
|
||||
QLabel *ui_casing_cm_cases_lbl;
|
||||
QLineEdit *ui_casing_cm_cases_textbox;
|
||||
QLabel *ui_log_lbl;
|
||||
QCheckBox *ui_log_cb;
|
||||
|
||||
bool needs_default_audiodev();
|
||||
|
||||
|
@ -699,6 +699,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
|
||||
|
||||
ui_casing_layout->setWidget(row, QFormLayout::FieldRole,
|
||||
ui_casing_cm_cases_textbox);
|
||||
//Check whether mass logging is enabled
|
||||
row += 1;
|
||||
ui_log_lbl = new QLabel(ui_casing_widget);
|
||||
ui_log_lbl->setText(tr("Automatic Logging:"));
|
||||
ui_log_lbl->setToolTip(
|
||||
tr("If checked, all logs will be automatically written in the "
|
||||
"/logs folder."));
|
||||
|
||||
ui_casing_layout->setWidget(row, QFormLayout::LabelRole, ui_log_lbl);
|
||||
|
||||
ui_log_cb = new QCheckBox(ui_casing_widget);
|
||||
ui_log_cb->setChecked(ao_app->get_auto_logging_enabled());
|
||||
|
||||
ui_casing_layout->setWidget(row, QFormLayout::FieldRole, ui_log_cb);
|
||||
|
||||
// When we're done, we should continue the updates!
|
||||
setUpdatesEnabled(true);
|
||||
@ -725,7 +739,7 @@ void AOOptionsDialog::save_pressed()
|
||||
configini->setValue("stickyeffects", ui_stickyeffects_cb->isChecked());
|
||||
configini->setValue("stickypres", ui_stickypres_cb->isChecked());
|
||||
configini->setValue("customchat", ui_customchat_cb->isChecked());
|
||||
|
||||
configini->setValue("automatic_logging_enabled", ui_log_cb->isChecked());
|
||||
QFile *callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");
|
||||
|
||||
if (callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate |
|
||||
|
@ -1870,7 +1870,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
||||
chatlogpiece *temp =
|
||||
new chatlogpiece(f_charname, f_showname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt());
|
||||
ic_chatlog_history.append(*temp);
|
||||
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
|
||||
if (ao_app->get_auto_logging_enabled())
|
||||
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
|
||||
|
||||
while (ic_chatlog_history.size() > log_maximum_blocks &&
|
||||
log_maximum_blocks > 0) {
|
||||
@ -3175,7 +3176,8 @@ void Courtroom::handle_song(QStringList *p_contents)
|
||||
if (!mute_map.value(n_char)) {
|
||||
chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true, m_chatmessage[TEXT_COLOR].toInt());
|
||||
ic_chatlog_history.append(*temp);
|
||||
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
|
||||
if (ao_app->get_auto_logging_enabled())
|
||||
ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true);
|
||||
|
||||
while (ic_chatlog_history.size() > log_maximum_blocks &&
|
||||
log_maximum_blocks > 0) {
|
||||
|
@ -292,13 +292,16 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
|
||||
// Remove any characters not accepted in folder names for the server_name
|
||||
// here
|
||||
this->log_filename = QDateTime::currentDateTime().toUTC().toString(
|
||||
"'logs/" + server_name.remove(QRegExp("[\\\\/:*?\"<>|\']")) +
|
||||
"/'ddd MMMM yyyy hh.mm.ss t'.log'");
|
||||
this->write_to_file("Joined server " + server_name + " on address " +
|
||||
server_address + " on " +
|
||||
QDateTime::currentDateTime().toUTC().toString(),
|
||||
log_filename, true);
|
||||
if (AOApplication::get_auto_logging_enabled()){
|
||||
this->log_filename = QDateTime::currentDateTime().toUTC().toString(
|
||||
"'logs/" + server_name.remove(QRegExp("[\\\\/:*?\"<>|\']")) +
|
||||
"/'ddd MMMM yyyy hh.mm.ss t'.log'");
|
||||
this->write_to_file("Joined server " + server_name + " on address " +
|
||||
server_address + " on " +
|
||||
QDateTime::currentDateTime().toUTC().toString(),
|
||||
log_filename, true);
|
||||
}
|
||||
|
||||
QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
|
||||
hash.addData(server_address.toUtf8());
|
||||
if (is_discord_enabled())
|
||||
|
@ -1049,3 +1049,9 @@ QString AOApplication::get_casing_can_host_cases()
|
||||
.value<QString>();
|
||||
return result;
|
||||
}
|
||||
bool AOApplication::get_auto_logging_enabled()
|
||||
{
|
||||
QString result =
|
||||
configini->value("automatic_logging_enabled", "true").value<QString>();
|
||||
return result.startsWith("true");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user