private static void LogFilesItem_Popup(object sender, EventArgs e)
{
AemInstance instance = Program.GetActionInstance(sender);
if (instance == null) {
return;
}
MenuItem logFilesItem = (MenuItem)sender;
logFilesItem.MenuItems.Clear();
string logsPath = instance.PathWithoutFilename + @"\crx-quickstart\logs";
if (Directory.Exists(logsPath)) {
string[] logFiles = Directory.GetFiles(logsPath);
if (logFiles.Length > 0) {
foreach (string logFilePath in logFiles) {
string logFile = logFilePath.Substring(logFilePath.LastIndexOf(@"\") + 1);
// skip logfiles with suffixes like ".2016-07-19", "", "-2016-07-12.log", "-4108.log"
if (Regex.Match(logFile, @"^.*\.\d+\-\d+\-\d+$").Success
|| Regex.Match(logFile, @"^.*\-\d+(\-\d+\-\d+)?\.log$").Success) {
continue;
}
MenuItem item = new MenuItem();
item.Text = logFile;
item.Click += new EventHandler(OpenLogFile);
item.Tag = instance;
logFilesItem.MenuItems.Add(item);
}
}
}
if (logFilesItem.MenuItems.Count == 0) {
logFilesItem.MenuItems.Add(new MenuItem("-- No logfiles --"));
}
}