mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Invert 'if' statement to reduce nesting.
This commit is contained in:
@@ -43,93 +43,90 @@ namespace DiscImageChef.Core.Logging
|
||||
|
||||
public DumpLog(string outputFile, Device dev)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(outputFile))
|
||||
if(string.IsNullOrEmpty(outputFile)) return;
|
||||
|
||||
logSw = new StreamWriter(outputFile, true);
|
||||
|
||||
logSw.WriteLine("Start logging at {0}", DateTime.Now);
|
||||
|
||||
Interop.PlatformID platId = Interop.DetectOS.GetRealPlatformID();
|
||||
string platVer = Interop.DetectOS.GetVersion();
|
||||
Type monoRunType = Type.GetType("Mono.Runtime");
|
||||
|
||||
logSw.WriteLine("################# System information #################");
|
||||
logSw.WriteLine("{0} {1} ({2}-bit)", Interop.DetectOS.GetPlatformName(platId, platVer), platVer,
|
||||
Environment.Is64BitOperatingSystem ? 64 : 32);
|
||||
if(monoRunType != null)
|
||||
{
|
||||
logSw = new StreamWriter(outputFile, true);
|
||||
|
||||
logSw.WriteLine("Start logging at {0}", DateTime.Now);
|
||||
|
||||
Interop.PlatformID platId = Interop.DetectOS.GetRealPlatformID();
|
||||
string platVer = Interop.DetectOS.GetVersion();
|
||||
Type monoRunType = Type.GetType("Mono.Runtime");
|
||||
|
||||
logSw.WriteLine("################# System information #################");
|
||||
logSw.WriteLine("{0} {1} ({2}-bit)", Interop.DetectOS.GetPlatformName(platId, platVer), platVer,
|
||||
Environment.Is64BitOperatingSystem ? 64 : 32);
|
||||
if(monoRunType != null)
|
||||
{
|
||||
string monoVer = "unknown version";
|
||||
MethodInfo monoDisplayName =
|
||||
monoRunType.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if(monoDisplayName != null) monoVer = (string)monoDisplayName.Invoke(null, null);
|
||||
logSw.WriteLine("Mono {0}", monoVer);
|
||||
}
|
||||
else logSw.WriteLine(".NET Framework {0}", Environment.Version);
|
||||
logSw.WriteLine();
|
||||
|
||||
logSw.WriteLine("################# Program information ################");
|
||||
logSw.WriteLine("DiscImageChef {0} running in {1}-bit", Version.GetVersion(),
|
||||
Environment.Is64BitProcess ? 64 : 32);
|
||||
#if DEBUG
|
||||
logSw.WriteLine("DEBUG version");
|
||||
#endif
|
||||
logSw.WriteLine("Command line: {0}", Environment.CommandLine);
|
||||
logSw.WriteLine();
|
||||
|
||||
logSw.WriteLine("################# Device information #################");
|
||||
logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer);
|
||||
logSw.WriteLine("Model: {0}", dev.Model);
|
||||
logSw.WriteLine("Firmware revision: {0}", dev.Revision);
|
||||
logSw.WriteLine("Serial number: {0}", dev.Serial);
|
||||
logSw.WriteLine("Removable device: {0}", dev.IsRemovable);
|
||||
logSw.WriteLine("Device type: {0}", dev.Type);
|
||||
logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash);
|
||||
logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia);
|
||||
logSw.WriteLine("USB device: {0}", dev.IsUsb);
|
||||
if(dev.IsUsb)
|
||||
{
|
||||
logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString);
|
||||
logSw.WriteLine("USB product: {0}", dev.UsbProductString);
|
||||
logSw.WriteLine("USB serial: {0}", dev.UsbSerialString);
|
||||
logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId);
|
||||
logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId);
|
||||
}
|
||||
logSw.WriteLine("FireWire device: {0}", dev.IsFireWire);
|
||||
if(dev.IsFireWire)
|
||||
{
|
||||
logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName);
|
||||
logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName);
|
||||
logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid);
|
||||
logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor);
|
||||
logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel);
|
||||
}
|
||||
logSw.WriteLine();
|
||||
logSw.WriteLine("######################################################");
|
||||
|
||||
logSw.WriteLine();
|
||||
logSw.WriteLine("################ Dumping progress log ################");
|
||||
logSw.Flush();
|
||||
string monoVer = "unknown version";
|
||||
MethodInfo monoDisplayName =
|
||||
monoRunType.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if(monoDisplayName != null) monoVer = (string)monoDisplayName.Invoke(null, null);
|
||||
logSw.WriteLine("Mono {0}", monoVer);
|
||||
}
|
||||
else logSw.WriteLine(".NET Framework {0}", Environment.Version);
|
||||
logSw.WriteLine();
|
||||
|
||||
logSw.WriteLine("################# Program information ################");
|
||||
logSw.WriteLine("DiscImageChef {0} running in {1}-bit", Version.GetVersion(),
|
||||
Environment.Is64BitProcess ? 64 : 32);
|
||||
#if DEBUG
|
||||
logSw.WriteLine("DEBUG version");
|
||||
#endif
|
||||
logSw.WriteLine("Command line: {0}", Environment.CommandLine);
|
||||
logSw.WriteLine();
|
||||
|
||||
logSw.WriteLine("################# Device information #################");
|
||||
logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer);
|
||||
logSw.WriteLine("Model: {0}", dev.Model);
|
||||
logSw.WriteLine("Firmware revision: {0}", dev.Revision);
|
||||
logSw.WriteLine("Serial number: {0}", dev.Serial);
|
||||
logSw.WriteLine("Removable device: {0}", dev.IsRemovable);
|
||||
logSw.WriteLine("Device type: {0}", dev.Type);
|
||||
logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash);
|
||||
logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia);
|
||||
logSw.WriteLine("USB device: {0}", dev.IsUsb);
|
||||
if(dev.IsUsb)
|
||||
{
|
||||
logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString);
|
||||
logSw.WriteLine("USB product: {0}", dev.UsbProductString);
|
||||
logSw.WriteLine("USB serial: {0}", dev.UsbSerialString);
|
||||
logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId);
|
||||
logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId);
|
||||
}
|
||||
logSw.WriteLine("FireWire device: {0}", dev.IsFireWire);
|
||||
if(dev.IsFireWire)
|
||||
{
|
||||
logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName);
|
||||
logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName);
|
||||
logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid);
|
||||
logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor);
|
||||
logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel);
|
||||
}
|
||||
logSw.WriteLine();
|
||||
logSw.WriteLine("######################################################");
|
||||
|
||||
logSw.WriteLine();
|
||||
logSw.WriteLine("################ Dumping progress log ################");
|
||||
logSw.Flush();
|
||||
}
|
||||
|
||||
public void WriteLine(string format, params object[] args)
|
||||
{
|
||||
if(logSw != null)
|
||||
{
|
||||
string text = string.Format(format, args);
|
||||
logSw.WriteLine("{0:s} {1}", DateTime.Now, text);
|
||||
logSw.Flush();
|
||||
}
|
||||
if(logSw == null) return;
|
||||
|
||||
string text = string.Format(format, args);
|
||||
logSw.WriteLine("{0:s} {1}", DateTime.Now, text);
|
||||
logSw.Flush();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if(logSw != null)
|
||||
{
|
||||
logSw.WriteLine("######################################################");
|
||||
logSw.WriteLine("End logging at {0}", DateTime.Now);
|
||||
logSw.Close();
|
||||
}
|
||||
if(logSw == null) return;
|
||||
|
||||
logSw.WriteLine("######################################################");
|
||||
logSw.WriteLine("End logging at {0}", DateTime.Now);
|
||||
logSw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user