Commit cff51443 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Add "Log Events to Disk" option/checkbox for terminal server "Events"

The "Events" log messages will now be logged to a disk file in
data/events*.log by default (unless this option is disabled).

If the "First node" is > 1, then the base filename will be
"events<first-node>", otherwise, it's just "events". This is because you
would not want multiple instances of sbbs writing to the same events.log
file - that would be chaos. These log files are subject the log
rotation/retention policy defined in SCFG.

This should resolve the FAQ for Windows sysops about what log file to
which their event log messages are being written.
parent 7e102c79
Pipeline #3217 passed with stage
in 9 minutes and 40 seconds
......@@ -391,7 +391,35 @@ static void bbs_start(void)
static void event_log_msg(log_msg_t* msg)
{
static FILE* LogStream;
if(msg==NULL) {
if(LogStream!=NULL)
fcloselog(LogStream);
LogStream=NULL;
return;
}
log_msg(EventsForm->Log, msg);
if(MainForm->EventsLogFile) {
AnsiString LogFileName = AnsiString(MainForm->cfg.logs_dir) + "events";
if(MainForm->bbs_startup.first_node > 1)
LogFileName += MainForm->bbs_startup.first_node;
LogFileName += ".log";
if(LogStream==NULL)
LogStream=fopenlog(&MainForm->cfg, LogFileName.c_str());
if(LogStream!=NULL) {
AnsiString Line=SystemTimeToDateTime(msg->time).FormatString("yyyy-mm-dd hh:mm:ss ");
Line+=AnsiString(msg->buf).Trim();
if(msg->repeated)
Line += " [x" + AnsiString(msg->repeated + 1) + "]";
Line+="\n";
fwritelog(AnsiString(Line).c_str(),Line.Length(),LogStream);
}
}
}
static void services_log_msg(log_msg_t* msg)
......@@ -1901,14 +1929,19 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender)
ErrorSoundFile=Registry->ReadString("ErrorSoundFile");
if(Registry->ValueExists("MailLogFile"))
MailLogFile=Registry->ReadInteger("MailLogFile");
MailLogFile=Registry->ReadBool("MailLogFile");
else
MailLogFile=true;
MailLogFile=true;
if(Registry->ValueExists("FtpLogFile"))
FtpLogFile=Registry->ReadInteger("FtpLogFile");
FtpLogFile=Registry->ReadBool("FtpLogFile");
else
FtpLogFile=true;
FtpLogFile=true;
if(Registry->ValueExists("EventsLogFile"))
EventsLogFile=Registry->ReadBool("EventsLogFile");
else
EventsLogFile=true;
Registry->CloseKey();
delete Registry;
......@@ -2238,6 +2271,10 @@ void __fastcall TMainForm::SaveRegistrySettings(TObject* Sender)
Registry->WriteBool("ToolBarVisible",Toolbar->Visible);
Registry->WriteBool("StatusBarVisible",StatusBar->Visible);
Registry->WriteBool("FtpLogFile", FtpLogFile);
Registry->WriteBool("MailLogFile", MailLogFile);
Registry->WriteBool("EventsLogFile", EventsLogFile);
Registry->WriteInteger("MaxLogLen",MaxLogLen);
Registry->WriteString("LoginCommand",LoginCommand);
......@@ -2375,6 +2412,7 @@ void __fastcall TMainForm::ImportSettings(TObject* Sender)
ImportFormSettings(IniFile,section="TelnetForm",TelnetForm);
ImportFont(IniFile,section,"LogFont",TelnetForm->Log->Font);
TelnetForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
EventsLogFile=IniFile->ReadBool(section,"EventsFile",true);
ImportFormSettings(IniFile,section="EventsForm",EventsForm);
ImportFont(IniFile,section,"LogFont",EventsForm->Log->Font);
......@@ -2386,7 +2424,7 @@ void __fastcall TMainForm::ImportSettings(TObject* Sender)
ImportFormSettings(IniFile,section="FtpForm",FtpForm);
ImportFont(IniFile,section,"LogFont",FtpForm->Log->Font);
FtpLogFile=IniFile->ReadInteger(section,"LogFile",true);
FtpLogFile=IniFile->ReadBool(section,"LogFile",true);
FtpForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
ImportFormSettings(IniFile,section="WebForm",WebForm);
......@@ -2395,7 +2433,7 @@ void __fastcall TMainForm::ImportSettings(TObject* Sender)
ImportFormSettings(IniFile,section="MailForm",MailForm);
ImportFont(IniFile,section,"LogFont",MailForm->Log->Font);
MailLogFile=IniFile->ReadInteger(section,"LogFile",true);
MailLogFile=IniFile->ReadBool(section,"LogFile",true);
MailForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
ImportFormSettings(IniFile,section="NodeForm",NodeForm);
......
object MainForm: TMainForm
Left = 733
Top = 639
Left = 420
Top = 574
Width = 793
Height = 398
Caption = 'Synchronet Control Panel'
......@@ -463,6 +463,7 @@ public: // User declarations
BOOL ServicesAutoStart;
bool MailLogFile;
bool FtpLogFile;
bool EventsLogFile;
AnsiString LoginCommand;
AnsiString ConfigCommand;
AnsiString Password;
......
......@@ -109,6 +109,8 @@ void __fastcall TTelnetCfgDlg::FormShow(TObject *Sender)
EventsCheckBox->Checked
=!(MainForm->bbs_startup.options&BBS_OPT_NO_EVENTS);
EventsLogFileCheckBox->Checked = MainForm->EventsLogFile;
RLoginEnabledCheckBoxClick(Sender);
SshEnabledCheckBoxClick(Sender);
PageControl->ActivePage=GeneralTabSheet;
......@@ -180,6 +182,7 @@ void __fastcall TTelnetCfgDlg::OKBtnClick(TObject *Sender)
else
MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_SSH;
MainForm->EventsLogFile = EventsLogFileCheckBox->Checked;
MainForm->SaveIniSettings(Sender);
}
//---------------------------------------------------------------------------
......
......@@ -17,8 +17,8 @@ object TelnetCfgDlg: TTelnetCfgDlg
Top = 3
Width = 278
Height = 186
ActivePage = SoundTabSheet
TabIndex = 4
ActivePage = GeneralTabSheet
TabIndex = 0
TabOrder = 0
object GeneralTabSheet: TTabSheet
Caption = 'General'
......@@ -101,7 +101,7 @@ object TelnetCfgDlg: TTelnetCfgDlg
end
object QWKEventsCheckBox: TCheckBox
Left = 148
Top = 88
Top = 114
Width = 117
Height = 20
Hint = 'Handle QWK Message Packet Events in This Instance'
......@@ -144,6 +144,17 @@ object TelnetCfgDlg: TTelnetCfgDlg
ShowHint = True
TabOrder = 2
end
object EventsLogFileCheckBox: TCheckBox
Left = 148
Top = 88
Width = 117
Height = 20
Hint = 'Save event log messages to disk file in your DATA directory'
Caption = 'Log Events to Disk'
ParentShowHint = False
ShowHint = True
TabOrder = 9
end
end
object TelnetTabSheet: TTabSheet
Caption = 'Telnet'
......
......@@ -96,6 +96,7 @@ __published:
TLabel *SshConnectTimeoutLabel;
TEdit *SshConnTimeoutEdit;
TButton *ConfigureSoundButton;
TCheckBox *EventsLogFileCheckBox;
void __fastcall FormShow(TObject *Sender);
void __fastcall OKBtnClick(TObject *Sender);
void __fastcall RLoginEnabledCheckBoxClick(TObject *Sender);
......
......@@ -5,7 +5,7 @@
<VERSION value="BCB.06.00"/>
<PROJECT value="sbbsctrl.exe"/>
<OBJFILES value="sbbsctrl.obj MainFormUnit.obj CtrlPathDialogUnit.obj TextFileEditUnit.obj
TelnetFormUnit.obj FtpFormUnit.obj MailFormUnit.obj NodeFormUnit.obj
TelnetFormUnit.obj FtpFormUnit.obj MailFormUnit.obj NodeFormUnit.obj ..\nopen.obj
StatsFormUnit.obj AboutBoxFormUnit.obj StatsLogFormUnit.obj
CodeInputFormUnit.obj ClientFormUnit.obj SpyFormUnit.obj ..\ringbuf.obj
emulvt.obj UserListFormUnit.obj UserMsgFormUnit.obj PropertiesDlgUnit.obj
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment