Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve visibility of logging from inside exception handlers #540

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ComponentToExternalReferenceInfoConverter(ILogger log)
}
catch (Exception e)
{
log.Debug($"Encountered an error while converting SBOM component {scannedComponent.Component.Id} to external reference: {e.Message}");
log.Warning($"Encountered an error while converting SBOM component {scannedComponent.Component.Id} to external reference: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = Entities.ErrorType.PackageError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ await errors.Writer.WriteAsync(new FileValidationResult
}
catch (Exception e)
{
log.Debug($"Encountered an error while converting external reference {externalDocumentRef.ExternalDocumentName} to path: {e.Message}");
log.Warning($"Encountered an error while converting external reference {externalDocumentRef.ExternalDocumentName} to path: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async Task ConvertComponentToPackage(ExtendedScannedComponent scannedComponent,
}
catch (Exception e)
{
log.Debug($"Encountered an error while processing package {scannedComponent.Component.Id}: {e.Message}");
log.Warning($"Encountered an error while processing package {scannedComponent.Component.Id}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.PackageError,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Executors/DirectoryWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async Task WalkDir(string path)
}
catch (Exception e)
{
log.Debug($"Encountered an unknown error for {path}: {e.Message}");
log.Warning($"Encountered an unknown error for {path}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Executors/EnumeratorChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async Task Enumerate()
}
catch (Exception e)
{
log.Debug($"Encountered an unknown error while enumerating: {e.Message}");
log.Warning($"Encountered an unknown error while enumerating: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Executors/FileFilterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ await errors.Writer.WriteAsync(new FileValidationResult
}
catch (Exception e)
{
log.Debug($"Encountered an error while filtering file {file.Path}: {e.Message}");
log.Warning($"Encountered an error while filtering file {file.Path}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Executors/FileInfoWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private async Task Generate(IList<ISbomConfig> filesArraySupportingSBOMs, Intern
}
catch (Exception e)
{
log.Debug($"Encountered an error while generating json for file {sbomFile.Path}: {e.Message}");
log.Warning($"Encountered an error while generating json for file {sbomFile.Path}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.JsonSerializationError,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Executors/ManifestFileFilterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ await errors.Writer.WriteAsync(new FileValidationResult
}
catch (Exception e)
{
log.Debug($"Encountered an error while filtering file {manifestFile} from the manifest: {e.Message}");
log.Warning($"Encountered an error while filtering file {manifestFile} from the manifest: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ await errors.Writer.WriteAsync(new FileValidationResult
}
catch (Exception e)
{
log.Debug($"Encountered an error while filtering file {file}: {e.Message}");
log.Warning($"Encountered an error while filtering file {file}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private async Task GenerateJson(
}
catch (Exception e)
{
log.Debug($"Encountered an error while generating json for packageInfo {packageInfo}: {e.Message}");
log.Warning($"Encountered an error while generating json for packageInfo {packageInfo}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.JsonSerializationError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ await errors.Writer.WriteAsync(new FileValidationResult
}
catch (HashGenerationException e)
{
log.Debug($"Encountered an error while generating hash for file {file}: {e.Message}");
log.Warning($"Encountered an error while generating hash for file {file}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand All @@ -115,7 +115,7 @@ await errors.Writer.WriteAsync(new FileValidationResult
}
catch (Exception e)
{
log.Debug($"Encountered an error while generating externalDocumentReferenceInfo from file {file}: {e.Message}");
log.Warning($"Encountered an error while generating externalDocumentReferenceInfo from file {file}: {e.Message}");
await errors.Writer.WriteAsync(new FileValidationResult
{
ErrorType = ErrorType.Other,
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.Sbom.Api/Output/MetadataBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public bool TryGetFilesArrayHeaderName(out string headerName)
catch (NotSupportedException)
{
headerName = null;
logger.Debug("Files array not suppored on this SBOM format.");
logger.Warning("Files array not suppored on this SBOM format.");
return false;
}
}
Expand All @@ -75,7 +75,7 @@ public bool TryGetPackageArrayHeaderName(out string headerName)
catch (NotSupportedException)
{
headerName = null;
logger.Debug("Packages array not suppored on this SBOM format.");
logger.Warning("Packages array not suppored on this SBOM format.");
return false;
}
}
Expand All @@ -90,7 +90,7 @@ public bool TryGetExternalRefArrayHeaderName(out string headerName)
catch (NotSupportedException)
{
headerName = null;
logger.Debug("External Document Reference array not suppored on this SBOM format.");
logger.Warning("External Document Reference array not suppored on this SBOM format.");
return false;
}
}
Expand All @@ -112,7 +112,7 @@ public bool TryGetRootPackageJson(IInternalMetadataProvider internalMetadataProv
catch (NotSupportedException)
{
generationResult = null;
logger.Debug("Root package serialization not supported on this SBOM format.");
logger.Warning("Root package serialization not supported on this SBOM format.");
return false;
}
}
Expand All @@ -127,7 +127,7 @@ public bool TryGetRelationshipsHeaderName(out string headerName)
catch (NotSupportedException)
{
headerName = null;
logger.Debug("Relationships array are not supported on this SBOM format.");
logger.Warning("Relationships array are not supported on this SBOM format.");
return false;
}
}
Expand Down