Register command statistics earlier.

This commit is contained in:
2019-01-05 20:21:57 +00:00
parent 372f9f68ac
commit a9f9b2f045
23 changed files with 24 additions and 34 deletions

View File

@@ -98,6 +98,7 @@
<e p="DiscImageChef.CommonTypes.csproj" t="IncludeRecursive" />
<e p="Enums" t="Include">
<e p="DeviceType.cs" t="Include" />
<e p="ErrorNumber.cs" t="Include" />
<e p="Images.cs" t="Include" />
</e>
<e p="Exceptions" t="Include">

View File

@@ -81,6 +81,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("analyze");
if(extra.Count > 1)
{
@@ -287,7 +288,6 @@ namespace DiscImageChef.Commands
return (int)ErrorNumber.UnexpectedException;
}
Statistics.AddCommand("analyze");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -73,6 +73,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("benchmark");
if(extra.Count != 0)
{
@@ -109,7 +110,6 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Max memory used is {0} bytes", results.MaxMemory);
DicConsole.WriteLine("Min memory used is {0} bytes", results.MinMemory);
Statistics.AddCommand("benchmark");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -108,6 +108,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("checksum");
if(extra.Count > 1)
{
@@ -305,7 +306,6 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Disk's {0}: {1}", chk.type, chk.Value);
}
Statistics.AddCommand("checksum");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -77,6 +77,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("compare");
if(extra.Count > 2)
{
@@ -398,7 +399,6 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine(sb.ToString());
Statistics.AddCommand("compare");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -162,6 +162,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("convert-image");
if(extra.Count > 2)
{
@@ -793,8 +794,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Conversion done.");
Statistics.AddCommand("convert-image");
return 0;
return (int)ErrorNumber.NoError;
}
}
}

View File

@@ -92,6 +92,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("create-sidecar");
if(extra.Count > 1)
{
@@ -201,8 +202,6 @@ namespace DiscImageChef.Commands
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
Statistics.AddCommand("create-sidecar");
}
catch(Exception ex)
{
@@ -236,8 +235,6 @@ namespace DiscImageChef.Commands
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
Statistics.AddCommand("create-sidecar");
}
else DicConsole.ErrorWriteLine("The specified input file cannot be found.");

View File

@@ -83,6 +83,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("decode");
if(extra.Count > 1)
{
@@ -318,7 +319,6 @@ namespace DiscImageChef.Commands
// TODO: Not implemented
}
Statistics.AddCommand("decode");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -80,6 +80,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("device-info");
if(extra.Count > 1)
{
@@ -907,10 +908,7 @@ namespace DiscImageChef.Commands
break;
}
Statistics.AddCommand("device-info");
dev.Close();
return (int)ErrorNumber.NoError;
}
}

View File

@@ -85,6 +85,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("device-report");
if(extra.Count > 1)
{
@@ -977,8 +978,6 @@ namespace DiscImageChef.Commands
jsonSw.Close();
jsonFs.Close();
Statistics.AddCommand("device-report");
using(DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath))
{
ctx.Reports.Add(new Report(report));

View File

@@ -134,6 +134,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("dump-media");
if(extra.Count > 2)
{
@@ -350,9 +351,6 @@ namespace DiscImageChef.Commands
}
dumpLog.Close();
Statistics.AddCommand("dump-media");
dev.Close();
return (int)ErrorNumber.NoError;
}

View File

@@ -86,6 +86,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("entropy");
if(extra.Count > 1)
{
@@ -153,7 +154,6 @@ namespace DiscImageChef.Commands
if(!wholeDisc)
{
Statistics.AddCommand("entropy");
return (int)ErrorNumber.NoError;
}
@@ -164,7 +164,6 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", entropy.UniqueSectors,
(double)entropy.UniqueSectors / (double)entropy.Sectors);
Statistics.AddCommand("entropy");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -90,6 +90,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("extract-files");
if(extra.Count > 1)
{
@@ -801,7 +802,6 @@ namespace DiscImageChef.Commands
return (int)ErrorNumber.UnexpectedException;
}
Statistics.AddCommand("extract-files");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -74,6 +74,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("formats");
if(extra.Count > 0)
{
@@ -153,7 +154,6 @@ namespace DiscImageChef.Commands
else
DicConsole.WriteLine(kvp.Value.Name);
Statistics.AddCommand("formats");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -75,6 +75,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("image-info");
if(extra.Count > 1)
{
@@ -146,7 +147,6 @@ namespace DiscImageChef.Commands
return (int)ErrorNumber.UnexpectedException;
}
Statistics.AddCommand("image-info");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -71,6 +71,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("list-devices");
if(extra.Count > 0)
{
@@ -98,7 +99,6 @@ namespace DiscImageChef.Commands
dev.Model, dev.Serial, dev.Bus, dev.Supported);
}
Statistics.AddCommand("list-devices");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -71,6 +71,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("list-encodings");
if(extra.Count > 0)
{
@@ -99,7 +100,6 @@ namespace DiscImageChef.Commands
foreach(CommonEncodingInfo info in encodings.OrderBy(t => t.DisplayName))
DicConsole.WriteLine("{0,-16} {1,-8}", info.Name, info.DisplayName);
Statistics.AddCommand("list-encodings");
return (int)ErrorNumber.NoError;
}

View File

@@ -83,6 +83,7 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("List-Options command", "--debug={0}", MainClass.Debug);
DicConsole.DebugWriteLine("List-Options command", "--verbose={0}", MainClass.Verbose);
Statistics.AddCommand("list-options");
PluginBase plugins = GetPluginBase.Instance;

View File

@@ -104,6 +104,7 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Ls command", "--input={0}", inputFile);
DicConsole.DebugWriteLine("Ls command", "--options={0}", pluginOptions);
DicConsole.DebugWriteLine("Ls command", "--verbose={0}", MainClass.Verbose);
Statistics.AddCommand("ls");
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(inputFile);
@@ -354,7 +355,6 @@ namespace DiscImageChef.Commands
return (int)ErrorNumber.UnexpectedException;
}
Statistics.AddCommand("ls");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -90,6 +90,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("media-info");
if(extra.Count > 1)
{
@@ -142,8 +143,6 @@ namespace DiscImageChef.Commands
default: throw new NotSupportedException("Unknown device type.");
}
Statistics.AddCommand("media-info");
return (int)ErrorNumber.NoError;
}

View File

@@ -77,6 +77,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("media-scan");
if(extra.Count > 1)
{
@@ -158,8 +159,6 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)",
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
Statistics.AddCommand("media-scan");
dev.Close();
return (int)ErrorNumber.NoError;
}

View File

@@ -80,6 +80,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("print-hex");
if(extra.Count > 1)
{
@@ -155,7 +156,6 @@ namespace DiscImageChef.Commands
PrintHex.PrintHexArray(sector, widthBytes);
}
Statistics.AddCommand("print-hex");
return (int)ErrorNumber.NoError;
}
}

View File

@@ -78,6 +78,7 @@ namespace DiscImageChef.Commands
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("verify");
if(extra.Count > 1)
{
@@ -293,8 +294,6 @@ namespace DiscImageChef.Commands
else if((ulong)unknownLbas.Count < inputFormat.Info.Sectors) correctSectors = true;
}
Statistics.AddCommand("verify");
switch(correctImage)
{
case null when correctSectors is null: return (int)ErrorNumber.NotVerificable;