Skip to content

Commit 308c1b0

Browse files
The Control Panel now says where the log files are
The last ⚠️ in CONTROL-PANEL-GAP-ANALYSIS.md. The classic Administrator's Logging pane showed the log directory and gave you a button to open it; the Control Panel had neither, so the first question anybody asks on that page - "where are these files?" - could only be answered by opening hMailServer.INI by hand. The live-logs page shows contents, which is a different question. A "Log files" card on the Logging tab, with the path read from [Directories] LogFolder and an Open log folder button. The path is read rather than assumed, and says so when it cannot be. The Control Panel can be run from a machine that is not the server, in which case there is no INI to read - and a button that cheerfully opened "the log folder" would open this machine's idea of one, which is worse than not offering it. The button reports the two ordinary failures for the same reason: a folder that is configured but not there, and no folder configured at all. AND A CAPTION ROW TYPE THAT DROPPED ITS CAPTION Writing that found a second thing. ComAction never called Annotate, so its Blurb was silently discarded - the same omission that was found and fixed on the checkbox row, whose comment says so. Every ComAction in the file until now happened to have no Blurb, so nothing looked missing; the first one that needed a caption would have set it and got nothing back. Fixed at the row type rather than worked around at the call site, which also attaches the caption to the button as accessible help text - where a note about what a button is going to do belongs, rather than in a separate node a screen reader only reaches after moving past the control. That is the same shape as the rest of this session's work: the defect was found by using the thing rather than by reading it.
1 parent 5f4027d commit 308c1b0

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

hmailserver/source/Tools/ControlPanel/Views/ServerSettingsView.xaml.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,15 @@ public override FrameworkElement CreateEditor(object value)
644644
panel.Children.Add(btn);
645645
panel.Children.Add(result_);
646646
SetAid(btn, "action-" + Slug(ButtonText));
647+
648+
// Blurb was silently dropped on this row type too - the same omission that
649+
// was found and fixed on the checkbox row. Every ComAction until now
650+
// happened to have no Blurb, so nothing was visibly missing; the first one
651+
// that needed a caption (the log folder path) would have set it and got
652+
// nothing. Annotate also attaches the text to the button as accessible
653+
// help, which is where a caption about what the button will do belongs.
654+
Annotate(btn, panel);
655+
647656
return panel;
648657
}
649658

@@ -1318,6 +1327,62 @@ private void BuildLogging()
13181327
IniStore = iniStore_
13191328
});
13201329
logging.Cards.Add(retention);
1330+
1331+
// The classic Administrator's Logging pane showed the log directory and gave
1332+
// you a button to open it. The Control Panel had neither, so the first
1333+
// question anybody asks on this page - "where are these files?" - could only
1334+
// be answered by opening hMailServer.INI by hand, and the live-logs page
1335+
// shows contents rather than a location.
1336+
//
1337+
// The path is read rather than assumed, and the blurb says so when it cannot
1338+
// be: the Control Panel can be run from a different machine to the server, in
1339+
// which case there is no INI to read and a button that opened "the log folder"
1340+
// would open the wrong machine's idea of one.
1341+
string logFolder = iniStore_ != null && iniStore_.IsAvailable
1342+
? iniStore_.GetLogFolder()
1343+
: null;
1344+
1345+
var logFiles = Card("Log files",
1346+
"Where the server writes the logs configured above.");
1347+
1348+
logFiles.Settings.Add(new ComAction
1349+
{
1350+
Label = "Log folder",
1351+
ButtonText = "Open log folder",
1352+
Blurb = string.IsNullOrWhiteSpace(logFolder)
1353+
? "Read from [Directories] LogFolder in hMailServer.INI, which is not readable from this machine - " +
1354+
"the Control Panel is running somewhere other than the server."
1355+
: logFolder,
1356+
Action = () => OpenLogFolder(logFolder)
1357+
});
1358+
1359+
logging.Cards.Add(logFiles);
1360+
}
1361+
1362+
/// <summary>
1363+
/// Opens the log folder in Explorer, and says why it could not rather than
1364+
/// failing silently - the two ordinary reasons are a Control Panel running away
1365+
/// from the server, and a LogFolder that names a directory which is not there.
1366+
/// </summary>
1367+
private static (bool ok, string text) OpenLogFolder(string path)
1368+
{
1369+
if (string.IsNullOrWhiteSpace(path))
1370+
return (false, "No log folder could be read from hMailServer.INI on this machine.");
1371+
1372+
if (!System.IO.Directory.Exists(path))
1373+
return (false, "The configured log folder does not exist on this machine: " + path);
1374+
1375+
try
1376+
{
1377+
using var process = System.Diagnostics.Process.Start(
1378+
new System.Diagnostics.ProcessStartInfo(path) { UseShellExecute = true });
1379+
1380+
return (true, "Opened " + path);
1381+
}
1382+
catch (Exception ex)
1383+
{
1384+
return (false, "Could not open the folder: " + ex.Message);
1385+
}
13211386
}
13221387

13231388
private void BuildPerformance()

0 commit comments

Comments
 (0)