Skip to content

Instantly share code, notes, and snippets.

@cbanner
Last active December 28, 2018 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbanner/62a88bf4b3e8029561652a1be45b47e4 to your computer and use it in GitHub Desktop.
Save cbanner/62a88bf4b3e8029561652a1be45b47e4 to your computer and use it in GitHub Desktop.
Part 1: Pseudo code demonstrating the pervasiveness of logging components when allowed to infiltrate classes.
public class SignatureAuthenticationProcedure : IAuthenticationProcedure
{
private readonly ILogger logger;
public SignatureAuthenticationProcedure(ILogger logger)
{
this.logger = logger;
}
public AuthenticationResult Authenticate(HttpRequest request)
{
this.logger.Trace("Beginning signature authentication procedure.");
AuthenticationResult result = AuthenticationResult.Failed;
try
{
this.logger.Trace("Validating timestamp.");
if(IsTimestampValid(request))
{
this.logger.Trace("Timestamp valid.");
this.logger.Trace("Validating signature.");
if(IsSignatureValid(request))
{
result = AuthenticationResult.Success;
this.logger.Information("Authentication successful.")
}
}
}
catch(Exception ex)
{
this.logger.Error(ex);
throw;
}
finally
{
this.logger.Trace("Completed signature authentication procedure.");
}
return result;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment