[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 public class PcmciaInfoViewModel : ViewModelBase
{ {
readonly byte[] _cis; const string MODULE_NAME = "PCMCIA Information ViewModel";
readonly Window _view; readonly byte[] _cis;
string _pcmciaCisText; readonly Window _view;
PcmciaCisModel _selectedCis; string _pcmciaCisText;
PcmciaCisModel _selectedCis;
internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view) internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view)
{ {
@@ -143,7 +144,7 @@ public class PcmciaInfoViewModel : ViewModelBase
}); });
} }
else 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; public string CisLabel => UI.Title_CIS;

View File

@@ -51,16 +51,17 @@ namespace Aaru.Gui.ViewModels.Tabs;
public sealed class ScsiInfoViewModel : ViewModelBase public sealed class ScsiInfoViewModel : ViewModelBase
{ {
readonly byte[] _configuration; const string MODULE_NAME = "SCSI Information ViewModel";
readonly byte[] _scsiModeSense10; readonly byte[] _configuration;
readonly byte[] _scsiModeSense6; readonly byte[] _scsiModeSense10;
readonly Window _view; readonly byte[] _scsiModeSense6;
string _evpdPageText; readonly Window _view;
string _mmcFeatureText; string _evpdPageText;
string _scsiModeSensePageText; string _mmcFeatureText;
object _selectedEvpdPage; string _scsiModeSensePageText;
object _selectedMmcFeature; object _selectedEvpdPage;
object _selectedModeSensePage; object _selectedMmcFeature;
object _selectedModeSensePage;
public ScsiInfoViewModel(byte[] scsiInquiryData, Inquiry? scsiInquiry, Dictionary<byte, byte[]> scsiEvpdPages, public ScsiInfoViewModel(byte[] scsiInquiryData, Inquiry? scsiInquiry, Dictionary<byte, byte[]> scsiEvpdPages,
Modes.DecodedMode? scsiMode, PeripheralDeviceTypes scsiType, byte[] scsiModeSense6, 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); evpdPageTitle = string.Format(UI.Page_0_h, page.Key);
evpdDecodedPage = UI.Undecoded; evpdDecodedPage = UI.Undecoded;
AaruConsole.DebugWriteLine("Device-Info command", AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Found_undecoded_SCSI_VPD_page_0, page.Key); Localization.Core.Found_undecoded_SCSI_VPD_page_0, page.Key);
break; break;
@@ -600,17 +601,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
Features.SeparatedFeatures ftr = Features.Separate(_configuration); 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); 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); ftr.CurrentProfile);
if(ftr.Descriptors != null) if(ftr.Descriptors != null)
foreach(Features.FeatureDescriptor desc in ftr.Descriptors) foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
{ {
string featureNumber = string.Format(Localization.Core.Feature_0, desc.Code); 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 string featureDescription = desc.Code switch
{ {
@@ -682,7 +683,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase
}); });
} }
else else
AaruConsole.DebugWriteLine("Device-Info command", AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors); 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 // How many sectors to read at once
const uint SECTORS_TO_READ = 256; const uint SECTORS_TO_READ = 256;
const string MODULE_NAME = "Image Checksum ViewModel";
readonly IMediaImage _inputFormat; readonly IMediaImage _inputFormat;
readonly Window _view; readonly Window _view;
bool _adler32Checked; bool _adler32Checked;
@@ -514,7 +515,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
mediaChecksum?.Update(hiddenSector); 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); currentTrack.Sequence, currentTrack.StartSector, currentTrack.EndSector);
if(ChecksumTracksChecked) if(ChecksumTracksChecked)

View File

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