Skip to content

Commit 59ad09e

Browse files
updated the code
1 parent 224ce46 commit 59ad09e

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

src/LCT.Common/Logging/LoggerHelper.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ private static void DisplaySettingsWithLogger(List<string> projectTypes, Diction
674674

675675
foreach (var projectType in projectTypes)
676676
{
677-
Logger.Info(projectType + ":\n\t");
677+
Logger.InfoFormat("{0}:\n\t", projectType);
678678

679679
if (projectConfigMap.TryGetValue(projectType, out var config))
680680
{
@@ -1256,9 +1256,10 @@ public static void WriteToConsoleTable(Dictionary<string, int> printData, Dictio
12561256
const string TimeTakenBy = "Time Taken By";
12571257
string separator = $"{"=",5}{string.Join("", Enumerable.Repeat("=", 88)),5}";
12581258

1259-
Logger.Info("\nSummary :\n" +
1259+
string summaryHeader = "\nSummary :\n" +
12601260
(!string.IsNullOrWhiteSpace(ProjectSummaryLink) ? ProjectSummaryLink + "\n" : "") +
1261-
separator);
1261+
separator;
1262+
Logger.Info(summaryHeader);
12621263
Logger.InfoFormat("{0,5}{1,-70} {2,5} {3,5} {4,5}\n{6}", "|", Feature, "|", Count, "|", "", separator);
12631264

12641265
foreach (var item in printData)
@@ -1284,7 +1285,7 @@ private static void LogTableRow(string key, int value)
12841285

12851286
if ((key == "Packages Not Uploaded Due To Error" || key == "Packages Not Existing in Remote Cache") && value > 0)
12861287
{
1287-
Logger.Error(row + "\n" + separator);
1288+
Logger.ErrorFormat("{0}\n{1}", row, separator);
12881289
}
12891290
else
12901291
{
@@ -1686,11 +1687,11 @@ public static void WriteFossologyStatusMessage(string message)
16861687
if (LoggerFactory.UseSpectreConsole)
16871688
{
16881689
WriteInfoWithMarkup($" [white]└──[/][yellow]{message}[/]");
1689-
Logger.Debug(" └── " + message);
1690+
Logger.DebugFormat(" └── {0}", message);
16901691
}
16911692
else
16921693
{
1693-
Logger.Warn("\t" + message);
1694+
Logger.WarnFormat("\t{0}", message);
16941695
}
16951696
}
16961697
/// <summary>
@@ -1702,11 +1703,11 @@ public static void WriteFossologyExceptionMessage(string message)
17021703
if (LoggerFactory.UseSpectreConsole)
17031704
{
17041705
WriteInfoWithMarkup($" [white]└──[/][red]{message}[/]");
1705-
Logger.Debug(" └── " + message);
1706+
Logger.DebugFormat(" └── {0}", message);
17061707
}
17071708
else
17081709
{
1709-
Logger.Error("\t" + message);
1710+
Logger.ErrorFormat("\t{0}", message);
17101711
}
17111712
}
17121713
/// <summary>
@@ -1756,7 +1757,7 @@ public static void MSBuildVersionDisplay(string message, string version)
17561757
}
17571758
else
17581759
{
1759-
Logger.Info(message + version);
1760+
Logger.InfoFormat("{0}{1}", message, version);
17601761
}
17611762
}
17621763
/// <summary>

src/LCT.SW360PackageCreator/PackageDownloader.cs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,35 +136,29 @@ private static string GetCorrectVersion(ComparisonBomData component)
136136
string[] taglist = GetTagListFromResult(result);
137137
string baseVersion = GetBaseVersion(component.Version);
138138

139-
foreach (string item in taglist)
139+
foreach (string item in taglist.Where(x => !string.IsNullOrWhiteSpace(x)))
140140
{
141-
if (!string.IsNullOrWhiteSpace(item))
142-
{
143-
string tag = item[(item.IndexOf("tags/") + 5)..];
144-
Logger.DebugFormat("baseobject - {0},Identifying tag -{1}", item, tag);
141+
string tag = item[(item.IndexOf("tags/") + 5)..];
142+
Logger.DebugFormat("baseobject - {0},Identifying tag -{1}", item, tag);
145143

146-
if (tag.Contains(component.Version, StringComparison.OrdinalIgnoreCase) &&
144+
if (tag.Contains(component.Version, StringComparison.OrdinalIgnoreCase) &&
147145
tag.Contains(component.Name, StringComparison.OrdinalIgnoreCase))
148-
{
149-
return tag;
150-
}
146+
{
147+
return tag;
151148
}
152149
}
153-
foreach (string item in taglist)
150+
foreach (string item in taglist.Where(x => !string.IsNullOrWhiteSpace(x)))
154151
{
155-
if (!string.IsNullOrWhiteSpace(item))
156-
{
157-
string tag = item[(item.IndexOf("tags/") + 5)..];
158-
Logger.DebugFormat("baseobject - {0},Identifying tag -{1}", item, tag);
152+
string tag = item[(item.IndexOf("tags/") + 5)..];
153+
Logger.DebugFormat("baseobject - {0},Identifying tag -{1}", item, tag);
159154

160-
if (tag.Contains(component.Version))
161-
{
162-
return tag;
163-
}
164-
else if (tag.Contains(baseVersion))
165-
{
166-
return tag;
167-
}
155+
if (tag.Contains(component.Version))
156+
{
157+
return tag;
158+
}
159+
else if (tag.Contains(baseVersion))
160+
{
161+
return tag;
168162
}
169163
}
170164
Logger.DebugFormat("GetCorrectVersion():Completed identifying correct version for this component ,given version:{0}, correct Version:{1}", component.Version, correctVersion);

src/LCT.Services/Sw360CreatorService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ public async Task<FossTriggerStatus> TriggerFossologyProcessForValidation(string
10471047
{
10481048
if (ex.Message == "500:Connection to Fossology server Failed.")
10491049
{
1050-
Logger.Error("Fossology process failed.Please check fossology configuration or Token in sw360");
1050+
Logger.Error("Fossology process failed.Please check fossology configuration or Token in sw360", ex);
10511051
environmentHelper.CallEnvironmentExit(-1);
10521052
}
10531053
}

0 commit comments

Comments
 (0)