[Aaru.Helpers] Introduced constants for module names

Introduces constant fields for respective debug module names, replacing the hardcoded ones.
This is done to standardize the naming convention, reduce redundancy and potentially avoid any typos or name mismatches across the project.
This change makes the code more maintainable and easier to update in case module names need to be changed.
This commit is contained in:
2023-10-03 17:50:40 +01:00
parent 4ef3252b24
commit 7fb3a87b24
5 changed files with 45 additions and 41 deletions

View File

@@ -47,10 +47,11 @@ namespace Aaru.Gui.ViewModels.Tabs;
public class PcmciaInfoViewModel : ViewModelBase
{
readonly byte[] _cis;
readonly Window _view;
string _pcmciaCisText;
PcmciaCisModel _selectedCis;
const string MODULE_NAME = "PCMCIA Information ViewModel";
readonly byte[] _cis;
readonly Window _view;
string _pcmciaCisText;
PcmciaCisModel _selectedCis;
internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view)
{
@@ -143,7 +144,7 @@ public class PcmciaInfoViewModel : ViewModelBase
});
}
else
AaruConsole.DebugWriteLine("Device-Info command", UI.PCMCIA_CIS_returned_no_tuples);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.PCMCIA_CIS_returned_no_tuples);
}
public string CisLabel => UI.Title_CIS;

View File

@@ -51,16 +51,17 @@ namespace Aaru.Gui.ViewModels.Tabs;
public sealed class ScsiInfoViewModel : ViewModelBase
{
readonly byte[] _configuration;
readonly byte[] _scsiModeSense10;
readonly byte[] _scsiModeSense6;
readonly Window _view;
string _evpdPageText;
string _mmcFeatureText;
string _scsiModeSensePageText;
object _selectedEvpdPage;
object _selectedMmcFeature;
object _selectedModeSensePage;
const string MODULE_NAME = "SCSI Information ViewModel";
readonly byte[] _configuration;
readonly byte[] _scsiModeSense10;
readonly byte[] _scsiModeSense6;
readonly Window _view;
string _evpdPageText;
string _mmcFeatureText;
string _scsiModeSensePageText;
object _selectedEvpdPage;
object _selectedMmcFeature;
object _selectedModeSensePage;
public ScsiInfoViewModel(byte[] scsiInquiryData, Inquiry? scsiInquiry, Dictionary<byte, byte[]> scsiEvpdPages,
Modes.DecodedMode? scsiMode, PeripheralDeviceTypes scsiType, byte[] scsiModeSense6,
@@ -580,7 +581,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase
evpdPageTitle = string.Format(UI.Page_0_h, page.Key);
evpdDecodedPage = UI.Undecoded;
AaruConsole.DebugWriteLine("Device-Info command",
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Found_undecoded_SCSI_VPD_page_0, page.Key);
break;
@@ -600,17 +601,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
Features.SeparatedFeatures ftr = Features.Separate(_configuration);
AaruConsole.DebugWriteLine("Device-Info command", Localization.Core.GET_CONFIGURATION_length_is_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_length_is_0,
ftr.DataLength);
AaruConsole.DebugWriteLine("Device-Info command", Localization.Core.GET_CONFIGURATION_current_profile_is_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_current_profile_is_0,
ftr.CurrentProfile);
if(ftr.Descriptors != null)
foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
{
string featureNumber = string.Format(Localization.Core.Feature_0, desc.Code);
AaruConsole.DebugWriteLine("Device-Info command", Localization.Core.Feature_0, desc.Code);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Feature_0, desc.Code);
string featureDescription = desc.Code switch
{
@@ -682,7 +683,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase
});
}
else
AaruConsole.DebugWriteLine("Device-Info command",
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors);
}

View File

@@ -52,6 +52,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
{
// How many sectors to read at once
const uint SECTORS_TO_READ = 256;
const string MODULE_NAME = "Image Checksum ViewModel";
readonly IMediaImage _inputFormat;
readonly Window _view;
bool _adler32Checked;
@@ -514,7 +515,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
mediaChecksum?.Update(hiddenSector);
}
AaruConsole.DebugWriteLine("Checksum command", UI.Track_0_starts_at_sector_1_and_ends_at_sector_2,
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Track_0_starts_at_sector_1_and_ends_at_sector_2,
currentTrack.Sequence, currentTrack.StartSector, currentTrack.EndSector);
if(ChecksumTracksChecked)

View File

@@ -72,21 +72,22 @@ namespace Aaru.Gui.ViewModels.Windows;
public sealed class MainWindowViewModel : ViewModelBase
{
readonly DevicesRootModel _devicesRoot;
readonly Bitmap _ejectIcon;
readonly Bitmap _genericFolderIcon;
readonly Bitmap _genericHddIcon;
readonly Bitmap _genericOpticalIcon;
readonly Bitmap _genericTapeIcon;
readonly ImagesRootModel _imagesRoot;
readonly Bitmap _removableIcon;
readonly Bitmap _sdIcon;
readonly Bitmap _usbIcon;
readonly MainWindow _view;
Views.Dialogs.Console _console;
object _contentPanel;
bool _devicesSupported;
object _treeViewSelectedItem;
const string MODULE_NAME = "Main Window ViewModel";
readonly DevicesRootModel _devicesRoot;
readonly Bitmap _ejectIcon;
readonly Bitmap _genericFolderIcon;
readonly Bitmap _genericHddIcon;
readonly Bitmap _genericOpticalIcon;
readonly Bitmap _genericTapeIcon;
readonly ImagesRootModel _imagesRoot;
readonly Bitmap _removableIcon;
readonly Bitmap _sdIcon;
readonly Bitmap _usbIcon;
readonly MainWindow _view;
Views.Dialogs.Console _console;
object _contentPanel;
bool _devicesSupported;
object _treeViewSelectedItem;
public MainWindowViewModel(MainWindow view)
{
@@ -593,7 +594,7 @@ public sealed class MainWindowViewModel : ViewModelBase
if(partitions.Count == 0)
{
AaruConsole.DebugWriteLine("Fs-info command", UI.No_partitions_found);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.No_partitions_found);
checkRaw = true;
}
@@ -768,7 +769,7 @@ public sealed class MainWindowViewModel : ViewModelBase
AaruConsole.ErrorWriteLine(UI.Unable_to_open_image_format);
AaruConsole.ErrorWriteLine(Localization.Core.Error_0, ex.Message);
AaruConsole.DebugWriteLine("Image-info command", Localization.Core.Stack_trace_0, ex.StackTrace);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Stack_trace_0, ex.StackTrace);
}
}
catch(Exception ex)
@@ -777,7 +778,7 @@ public sealed class MainWindowViewModel : ViewModelBase
Icon.Error);
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.DebugWriteLine("Image-info command", ex.StackTrace);
AaruConsole.DebugWriteLine(MODULE_NAME, ex.StackTrace);
}
Statistics.AddCommand("image-info");
@@ -800,7 +801,7 @@ public sealed class MainWindowViewModel : ViewModelBase
foreach(Devices.DeviceInfo device in Device.ListDevices().Where(d => d.Supported).OrderBy(d => d.Vendor).
ThenBy(d => d.Model))
{
AaruConsole.DebugWriteLine("Main window",
AaruConsole.DebugWriteLine(MODULE_NAME,
UI.Found_supported_device_model_0_by_manufacturer_1_on_bus_2_and_path_3,
device.Model, device.Vendor, device.Bus, device.Path);