From 6e54d5c3800eaee107dd01568a6946fac45c0ded Mon Sep 17 00:00:00 2001 From: Scott Arbeit Date: Tue, 12 Dec 2023 02:11:10 -0800 Subject: [PATCH] Bug fixes for CLI reference handling. Logging cleanup. --- src/Grace.Actors/Branch.Actor.fs | 8 ++--- src/Grace.Actors/BranchName.Actor.fs | 4 +-- src/Grace.Actors/Diff.Actor.fs | 8 ++--- src/Grace.Actors/DirectoryVersion.Actor.fs | 8 ++--- src/Grace.Actors/Organization.Actor.fs | 8 ++--- src/Grace.Actors/OrganizationName.Actor.fs | 2 +- src/Grace.Actors/Owner.Actor.fs | 8 ++--- src/Grace.Actors/OwnerName.Actor.fs | 2 +- src/Grace.Actors/Reference.Actor.fs | 4 +-- src/Grace.Actors/Repository.Actor.fs | 8 ++--- src/Grace.Actors/RepositoryName.Actor.fs | 2 +- src/Grace.Actors/Services.Actor.fs | 11 ++++-- src/Grace.CLI/Command/Branch.CLI.fs | 4 +-- src/Grace.CLI/Command/Diff.CLI.fs | 25 ++++++------- src/Grace.CLI/Command/Maintenance.CLI.fs | 4 +-- src/Grace.CLI/Command/Services.CLI.fs | 2 +- src/Grace.CLI/Command/Watch.CLI.fs | 10 +++--- src/Grace.Server/Branch.Server.fs | 42 +++++++++++----------- src/Grace.Server/Repository.Server.fs | 25 ++++++------- src/Grace.Shared/Utilities.Shared.fs | 2 +- 20 files changed, 95 insertions(+), 92 deletions(-) diff --git a/src/Grace.Actors/Branch.Actor.fs b/src/Grace.Actors/Branch.Actor.fs index 90f6e1c..0e525f9 100644 --- a/src/Grace.Actors/Branch.Actor.fs +++ b/src/Grace.Actors/Branch.Actor.fs @@ -98,8 +98,8 @@ module Branch = | Some retrievedDto -> branchDto <- retrievedDto | None -> branchDto <- BranchDto.Default - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration_ms) } :> Task member private this.SetMaintenanceReminder() = @@ -130,9 +130,9 @@ module Branch = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") if String.IsNullOrEmpty(currentCommand) then - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) else - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/BranchName.Actor.fs b/src/Grace.Actors/BranchName.Actor.fs index 1adc077..56f0530 100644 --- a/src/Grace.Actors/BranchName.Actor.fs +++ b/src/Grace.Actors/BranchName.Actor.fs @@ -32,8 +32,8 @@ module BranchName = Task.CompletedTask override this.OnPostActorMethodAsync(context) = - let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds * 1000.0).ToString("F0") - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/Diff.Actor.fs b/src/Grace.Actors/Diff.Actor.fs index 6bed1ec..7c21a79 100644 --- a/src/Grace.Actors/Diff.Actor.fs +++ b/src/Grace.Actors/Diff.Actor.fs @@ -141,8 +141,8 @@ module Diff = | Some retrievedDto -> diffDto <- retrievedDto | None -> diffDto <- DiffDto.Default - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration_ms) } :> Task override this.OnPreActorMethodAsync(context) = @@ -152,8 +152,8 @@ module Diff = Task.CompletedTask override this.OnPostActorMethodAsync(context) = - let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds * 1000.0).ToString("F0") - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/DirectoryVersion.Actor.fs b/src/Grace.Actors/DirectoryVersion.Actor.fs index e93cb1f..9347608 100644 --- a/src/Grace.Actors/DirectoryVersion.Actor.fs +++ b/src/Grace.Actors/DirectoryVersion.Actor.fs @@ -51,8 +51,8 @@ module DirectoryVersion = log.LogError("{CurrentInstant} Error in {ActorType} {ActorId}.", getCurrentInstantExtended(), this.GetType().Name, host.Id) log.LogError("{CurrentInstant} {ExceptionDetails}", getCurrentInstantExtended(), exc.ToString()) - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration_ms) } :> Task override this.OnPreActorMethodAsync(context) = @@ -62,8 +62,8 @@ module DirectoryVersion = Task.CompletedTask override this.OnPostActorMethodAsync(context) = - let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds * 1000.0).ToString("F0") - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/Organization.Actor.fs b/src/Grace.Actors/Organization.Actor.fs index fd37751..23e0b1e 100644 --- a/src/Grace.Actors/Organization.Actor.fs +++ b/src/Grace.Actors/Organization.Actor.fs @@ -70,8 +70,8 @@ module Organization = | Some retrievedDto -> organizationDto <- retrievedDto | None -> organizationDto <- OrganizationDto.Default - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration) } :> Task member private this.SetMaintenanceReminder() = @@ -102,9 +102,9 @@ module Organization = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") if String.IsNullOrEmpty(currentCommand) then - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) else - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/OrganizationName.Actor.fs b/src/Grace.Actors/OrganizationName.Actor.fs index d7350d9..47bda16 100644 --- a/src/Grace.Actors/OrganizationName.Actor.fs +++ b/src/Grace.Actors/OrganizationName.Actor.fs @@ -34,7 +34,7 @@ module OrganizationName = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; OrganizationName: {OrganizationName}; OrganizationId: {OrganizationId}; Duration: {duration}ms.", + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; OrganizationName: {OrganizationName}; OrganizationId: {OrganizationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, (if Option.isSome cachedOrganizationId then cachedOrganizationId.Value else "None"), duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/Owner.Actor.fs b/src/Grace.Actors/Owner.Actor.fs index 4e6169b..95b276e 100644 --- a/src/Grace.Actors/Owner.Actor.fs +++ b/src/Grace.Actors/Owner.Actor.fs @@ -70,8 +70,8 @@ module Owner = | Some retrievedDto -> ownerDto <- retrievedDto | None -> ownerDto <- OwnerDto.Default - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration_ms) } :> Task member private this.SetMaintenanceReminder() = @@ -104,9 +104,9 @@ module Owner = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") if String.IsNullOrEmpty(currentCommand) then - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) else - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/OwnerName.Actor.fs b/src/Grace.Actors/OwnerName.Actor.fs index 51c15b9..e8e073a 100644 --- a/src/Grace.Actors/OwnerName.Actor.fs +++ b/src/Grace.Actors/OwnerName.Actor.fs @@ -35,7 +35,7 @@ module OwnerName = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; OwnerName: {OwnerName}; OwnerId: {ownerId}; Duration: {duration}ms.", + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; OwnerName: {OwnerName}; OwnerId: {ownerId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, (if Option.isSome cachedOwnerId then cachedOwnerId.Value else "None"), duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/Reference.Actor.fs b/src/Grace.Actors/Reference.Actor.fs index 49cbb69..eab6b18 100644 --- a/src/Grace.Actors/Reference.Actor.fs +++ b/src/Grace.Actors/Reference.Actor.fs @@ -39,8 +39,8 @@ module Reference = | Some retrievedDto -> referenceDto <- Some retrievedDto | None -> () - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration_ms) } :> Task interface IReferenceActor with diff --git a/src/Grace.Actors/Repository.Actor.fs b/src/Grace.Actors/Repository.Actor.fs index 8653860..ccfba80 100644 --- a/src/Grace.Actors/Repository.Actor.fs +++ b/src/Grace.Actors/Repository.Actor.fs @@ -61,8 +61,8 @@ module Repository = | Some retrievedDto -> repositoryDto <- retrievedDto | None -> repositoryDto <- RepositoryDto.Default - let duration = getCurrentInstant().Minus(activateStartTime) - log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration}ms.", getCurrentInstantExtended(), actorName, host.Id, duration.TotalMilliseconds.ToString("F3")) + let duration_ms = getCurrentInstant().Minus(activateStartTime).TotalMilliseconds.ToString("F3") + log.LogInformation("{CurrentInstant}: Activated {ActorType} {ActorId}. Retrieved from storage in {duration_ms}ms.", getCurrentInstantExtended(), actorName, host.Id, duration_ms) } :> Task override this.OnPreActorMethodAsync(context) = @@ -82,9 +82,9 @@ module Repository = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") if String.IsNullOrEmpty(currentCommand) then - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, duration_ms) else - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; Command: {Command}; Id: {Id}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, currentCommand, this.Id, duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/RepositoryName.Actor.fs b/src/Grace.Actors/RepositoryName.Actor.fs index 3fc2730..6809163 100644 --- a/src/Grace.Actors/RepositoryName.Actor.fs +++ b/src/Grace.Actors/RepositoryName.Actor.fs @@ -35,7 +35,7 @@ module RepositoryName = override this.OnPostActorMethodAsync(context) = let duration_ms = (getCurrentInstant().Minus(actorStartTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; RepositoryName: {RepositoryName}; RepositoryId: {RepositoryId}; Duration: {duration}ms.", + log.LogInformation("{CurrentInstant}: Finished {ActorName}.{MethodName}; RepositoryName: {RepositoryName}; RepositoryId: {RepositoryId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), actorName, context.MethodName, this.Id, (if Option.isSome cachedRepositoryId then cachedRepositoryId.Value else "None"), duration_ms) logScope.Dispose() Task.CompletedTask diff --git a/src/Grace.Actors/Services.Actor.fs b/src/Grace.Actors/Services.Actor.fs index 6daf8cd..35bd0c4 100644 --- a/src/Grace.Actors/Services.Actor.fs +++ b/src/Grace.Actors/Services.Actor.fs @@ -957,7 +957,7 @@ module Services = let mutable requestCharge = 0.0 let mutable clientElapsedTime = TimeSpan.Zero - // In order to build the IN clause, we need to create a parameter for each referenceId. (I tried just using string concatenation, it didn't work for some reason.) + // In order to build the IN clause, we need to create a parameter for each referenceId. (I tried just using string concatenation, it didn't work for some reason. Anyway...) // The query starts with: let queryText = StringBuilder(@"SELECT TOP @maxCount c[""value""] FROM c WHERE c[""value""].Class = @class and c[""value""].ReferenceId IN (") // Then we add a parameter for each referenceId. @@ -968,7 +968,7 @@ module Services = // Create the query definition. let queryDefinition = QueryDefinition(queryText.ToString()) .WithParameter("@maxCount", referenceIds.Count()) - .WithParameter("@class", "ReferenceDto") + .WithParameter("@class", nameof(ReferenceDto)) // Add a .WithParameter for each referenceId. referenceIds |> Seq.iteri (fun i referenceId -> queryDefinition.WithParameter($"@referenceId{i}", $"{referenceId}") |> ignore) @@ -987,7 +987,12 @@ module Services = results.Resource |> Seq.iter (fun refDto -> queryResults.Add(refDto.value.ReferenceId, refDto.value)) // Add the results to the list in the same order as the supplied referenceIds. - referenceIds |> Seq.iter (fun referenceId -> referenceDtos.Add(queryResults[referenceId])) + referenceIds |> Seq.iter (fun referenceId -> + if referenceId <> ReferenceId.Empty then + referenceDtos.Add(queryResults[referenceId]) + else + // In case the caller supplied an empty referenceId, add a default ReferenceDto. + referenceDtos.Add(ReferenceDto.Default)) Activity.Current.SetTag("referenceDtos.Count", $"{referenceDtos.Count}") .SetTag("clientElapsedTime", $"{clientElapsedTime}") diff --git a/src/Grace.CLI/Command/Branch.CLI.fs b/src/Grace.CLI/Command/Branch.CLI.fs index 1a087e2..6e048c0 100644 --- a/src/Grace.CLI/Command/Branch.CLI.fs +++ b/src/Grace.CLI/Command/Branch.CLI.fs @@ -1835,9 +1835,9 @@ module Branch = $" None" else if parseResult |> verbose then - $" {getShortenedSha256Hash referenceDto.Sha256Hash} - {ago referenceDto.CreatedAt} - {instantToLocalTime referenceDto.CreatedAt} [{Colors.Deemphasized}]- {referenceDto.ReferenceId} - {referenceDto.DirectoryId}[/]" + $" {getShortSha256Hash referenceDto.Sha256Hash} - {ago referenceDto.CreatedAt} - {instantToLocalTime referenceDto.CreatedAt} [{Colors.Deemphasized}]- {referenceDto.ReferenceId} - {referenceDto.DirectoryId}[/]" else - $" {getShortenedSha256Hash referenceDto.Sha256Hash} - {ago referenceDto.CreatedAt} - {instantToLocalTime referenceDto.CreatedAt} [{Colors.Deemphasized}]- {referenceDto.ReferenceId}[/]" + $" {getShortSha256Hash referenceDto.Sha256Hash} - {ago referenceDto.CreatedAt} - {instantToLocalTime referenceDto.CreatedAt} [{Colors.Deemphasized}]- {referenceDto.ReferenceId}[/]" let permissions (branchDto: Dto.Branch.BranchDto) = let sb = StringBuilder() diff --git a/src/Grace.CLI/Command/Diff.CLI.fs b/src/Grace.CLI/Command/Diff.CLI.fs index b9e7c10..23e34b1 100644 --- a/src/Grace.CLI/Command/Diff.CLI.fs +++ b/src/Grace.CLI/Command/Diff.CLI.fs @@ -139,12 +139,13 @@ module Diff = else $"{diffLine.Position,6:D}: {diffLine.Text.EscapeMarkup()}" let private getMarkup (diffLine: DiffPiece) = - if diffLine.Type = ChangeType.Deleted then Markup($"[{Colors.Deleted}]-{renderLine diffLine}[/]") - elif diffLine.Type = ChangeType.Inserted then Markup($"[{Colors.Added}]+{renderLine diffLine}[/]") - elif diffLine.Type = ChangeType.Modified then Markup($"[{Colors.Changed}]~{renderLine diffLine}[/]") - elif diffLine.Type = ChangeType.Imaginary then Markup($"[{Colors.Deemphasized}] {renderLine diffLine}[/]") - elif diffLine.Type = ChangeType.Unchanged then Markup($"[{Colors.Important}] {renderLine diffLine}[/]") - else Markup($"[{Colors.Important}] {diffLine.Text}[/]") + match diffLine.Type with + | ChangeType.Deleted -> Markup($"[{Colors.Deleted}]-{renderLine diffLine}[/]") + | ChangeType.Inserted -> Markup($"[{Colors.Added}]+{renderLine diffLine}[/]") + | ChangeType.Modified -> Markup($"[{Colors.Changed}]~{renderLine diffLine}[/]") + | ChangeType.Imaginary -> Markup($"[{Colors.Deemphasized}] {renderLine diffLine}[/]") + | ChangeType.Unchanged -> Markup($"[{Colors.Important}] {renderLine diffLine}[/]") + | _ -> Markup($"[{Colors.Important}] {diffLine.Text}[/]") /// Creates the text output for a diff to the most recent specific ReferenceType. type GetDiffByReferenceTypeParameters() = @@ -299,7 +300,7 @@ module Diff = // There should only be one reference, because we're using MaxCount = 1. let references = returnValue.ReturnValue if references.Count() > 0 then - logToAnsiConsole Colors.Verbose $"Got latest reference: {references.First().ReferenceText}; {references.First().CreatedAt}; {getShortenedSha256Hash (references.First().Sha256Hash)}; {references.First().DirectoryId}." + //logToAnsiConsole Colors.Verbose $"Got latest reference: {references.First().ReferenceText}; {references.First().CreatedAt}; {getShortenedSha256Hash (references.First().Sha256Hash)}; {references.First().DirectoryId}." references.First() else logToAnsiConsole Colors.Error $"Error getting latest reference. No matching references were found." @@ -323,7 +324,7 @@ module Diff = // Sending diff request to server. t6.StartTask() - logToAnsiConsole Colors.Verbose $"latestReference.DirectoryId: {latestReference.DirectoryId}; rootDirectoryId: {rootDirectoryId}." + //logToAnsiConsole Colors.Verbose $"latestReference.DirectoryId: {latestReference.DirectoryId}; rootDirectoryId: {rootDirectoryId}." let getDiffParameters = GetDiffParameters(DirectoryId1 = latestReference.DirectoryId, DirectoryId2 = rootDirectoryId) let! getDiffResult = Diff.GetDiff(getDiffParameters) match getDiffResult with @@ -341,13 +342,9 @@ module Diff = for fileDiff in diffDto.FileDiffs.OrderBy(fun fileDiff -> fileDiff.RelativePath) do //addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath}[/]")).LeftAligned()) if fileDiff.CreatedAt1 > fileDiff.CreatedAt2 then - //addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath} | {fileDiff.CreatedAt1 |> instantToLocalTime} ({fileDiff.CreatedAt1 |> ago}) {fileDiff.FileSha1.Substring(0, 8)} | {fileDiff.CreatedAt2 |> instantToLocalTime} ({fileDiff.CreatedAt2 |> ago}) {fileDiff.FileSha2.Substring(0, 8)}[/]")).LeftAligned()) - addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath} | {fileDiff.FileSha1.Substring(0, 8)} - {fileDiff.CreatedAt1 |> ago} | {fileDiff.FileSha2.Substring(0, 8)} - {fileDiff.CreatedAt2 |> ago}[/]")).LeftJustified()) - //addToOutput (Markup($"[{Colors.Important}] {fileDiff.CreatedAt1 |> instantToLocalTime} ({fileDiff.CreatedAt1 |> ago}) {fileDiff.FileSha1.Substring(0, 8)} vs. {fileDiff.CreatedAt2 |> instantToLocalTime} ({fileDiff.CreatedAt2 |> ago}) {fileDiff.FileSha2.Substring(0, 8)}[/]")) + addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath} | {getShortSha256Hash fileDiff.FileSha1} - {fileDiff.CreatedAt1 |> ago} | {getShortSha256Hash fileDiff.FileSha2} - {fileDiff.CreatedAt2 |> ago}[/]")).LeftJustified()) else - //addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath} | {fileDiff.CreatedAt1 |> instantToLocalTime} ({fileDiff.CreatedAt1 |> ago}) {fileDiff.FileSha1.Substring(0, 8)} | {fileDiff.CreatedAt2 |> instantToLocalTime} ({fileDiff.CreatedAt2 |> ago}) {fileDiff.FileSha2.Substring(0, 8)}[/]")).LeftAligned()) - addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath} | {fileDiff.FileSha2.Substring(0, 8)} - {fileDiff.CreatedAt2 |> ago} | {fileDiff.FileSha1.Substring(0, 8)} - {fileDiff.CreatedAt1 |> ago}[/]")).LeftJustified()) - //addToOutput (Markup($"[{Colors.Important}] {fileDiff.CreatedAt2 |> instantToLocalTime} ({fileDiff.CreatedAt2 |> ago}) {fileDiff.FileSha2.Substring(0, 8)} vs. {fileDiff.CreatedAt1 |> instantToLocalTime} ({fileDiff.CreatedAt1 |> ago}) {fileDiff.FileSha1.Substring(0, 8)}[/]")) + addToOutput ((new Rule($"[{Colors.Important}]{fileDiff.RelativePath} | {getShortSha256Hash fileDiff.FileSha2} - {fileDiff.CreatedAt2 |> ago} | {getShortSha256Hash fileDiff.FileSha1} - {fileDiff.CreatedAt1 |> ago}[/]")).LeftJustified()) if fileDiff.IsBinary then addToOutput (Markup($"[{Colors.Important}]Binary file.[/]")) diff --git a/src/Grace.CLI/Command/Maintenance.CLI.fs b/src/Grace.CLI/Command/Maintenance.CLI.fs index 595eaff..143ead0 100644 --- a/src/Grace.CLI/Command/Maintenance.CLI.fs +++ b/src/Grace.CLI/Command/Maintenance.CLI.fs @@ -329,11 +329,11 @@ module Maintenance = AnsiConsole.MarkupLine($"[{Colors.Important}] Last Write Time SHA-256 Size Path{additionalSpaces}[/][{Colors.Deemphasized}](DirectoryVersionId)[/]") AnsiConsole.MarkupLine($"[{Colors.Important}] ----------------------------------------------------{additionalImportantDashes}[/][{Colors.Deemphasized}]{additionalDeemphasizedDashes}[/]") let rightAlignedDirectoryVersionId = (String.replicate (longestRelativePath - directoryVersion.RelativePath.Length) " ") + $"({directoryVersion.DirectoryId})" - AnsiConsole.MarkupLine($"[{Colors.Highlighted}]{directoryVersion.LastWriteTimeUtc,27} {getShortenedSha256Hash directoryVersion.Sha256Hash} {directoryVersion.Size,13:N0} /{directoryVersion.RelativePath}[/] [{Colors.Deemphasized}]{rightAlignedDirectoryVersionId}[/]") + AnsiConsole.MarkupLine($"[{Colors.Highlighted}]{directoryVersion.LastWriteTimeUtc,27} {getShortSha256Hash directoryVersion.Sha256Hash} {directoryVersion.Size,13:N0} /{directoryVersion.RelativePath}[/] [{Colors.Deemphasized}]{rightAlignedDirectoryVersionId}[/]") if parseResult.HasOption(Options.listFiles) then let sortedFiles = directoryVersion.Files.OrderBy(fun f -> f.RelativePath) for file in sortedFiles do - AnsiConsole.MarkupLine($"[{Colors.Verbose}]{file.LastWriteTimeUtc,27} {getShortenedSha256Hash file.Sha256Hash} {file.Size,13:N0} |- {file.FileInfo.Name}[/]") + AnsiConsole.MarkupLine($"[{Colors.Verbose}]{file.LastWriteTimeUtc,27} {getShortSha256Hash file.Sha256Hash} {file.Size,13:N0} |- {file.FileInfo.Name}[/]") ) } :> Task) diff --git a/src/Grace.CLI/Command/Services.CLI.fs b/src/Grace.CLI/Command/Services.CLI.fs index b53c8a8..542c455 100644 --- a/src/Grace.CLI/Command/Services.CLI.fs +++ b/src/Grace.CLI/Command/Services.CLI.fs @@ -868,7 +868,7 @@ module Services = // file in the working directory, and copy the version from the object cache to replace it. if uint64 existingFileOnDisk.Length <> fileVersion.Size || fileVersionFromPreviousGraceStatus.Sha256Hash <> fileVersion.Sha256Hash then - //logToAnsiConsole Colors.Verbose $"Replacing {fileVersion.FullName}; previous length: {fileVersionFromPreviousGraceStatus.Size}; new length: {fileVersion.Size}." + logToAnsiConsole Colors.Verbose $"Replacing {fileVersion.FullName}; previous length: {fileVersionFromPreviousGraceStatus.Size}; new length: {fileVersion.Size}." existingFileOnDisk.Delete() File.Copy(fileVersion.FullObjectPath, fileVersion.FullName) else diff --git a/src/Grace.CLI/Command/Watch.CLI.fs b/src/Grace.CLI/Command/Watch.CLI.fs index ec1951d..ef7dfbf 100644 --- a/src/Grace.CLI/Command/Watch.CLI.fs +++ b/src/Grace.CLI/Command/Watch.CLI.fs @@ -131,7 +131,7 @@ module Watch = // Ignore directory creation; need to think about this more... should we capture new empty directories? if updateNotInProgress() && isNotDirectory args.FullPath then let shouldIgnore = shouldIgnoreFile args.FullPath - logToAnsiConsole Colors.Verbose $"Should ignore {args.FullPath}: {shouldIgnore}." + //logToAnsiConsole Colors.Verbose $"Should ignore {args.FullPath}: {shouldIgnore}." if not <| shouldIgnore then logToAnsiConsole Colors.Added $"I saw that {args.FullPath} was created." @@ -140,7 +140,7 @@ module Watch = let OnChanged (args: FileSystemEventArgs) = if updateNotInProgress() && isNotDirectory args.FullPath then let shouldIgnore = shouldIgnoreFile args.FullPath - logToAnsiConsole Colors.Verbose $"Should ignore {args.FullPath}: {shouldIgnore}." + //logToAnsiConsole Colors.Verbose $"Should ignore {args.FullPath}: {shouldIgnore}." if not <| shouldIgnore then logToAnsiConsole Colors.Changed $"I saw that {args.FullPath} changed." @@ -155,7 +155,7 @@ module Watch = let OnDeleted (args: FileSystemEventArgs) = if updateNotInProgress() && isNotDirectory args.FullPath then let shouldIgnore = shouldIgnoreFile args.FullPath - logToAnsiConsole Colors.Verbose $"Should ignore {args.FullPath}: {shouldIgnore}." + //logToAnsiConsole Colors.Verbose $"Should ignore {args.FullPath}: {shouldIgnore}." if not <| shouldIgnore then logToAnsiConsole Colors.Deleted $"I saw that {args.FullPath} was deleted." @@ -168,12 +168,12 @@ module Watch = if not <| shouldIgnoreOldFile then logToAnsiConsole Colors.Changed $"I saw that {args.OldFullPath} was renamed to {args.FullPath}." - logToAnsiConsole Colors.Verbose $"Should ignore {args.OldFullPath}: {shouldIgnoreOldFile}. Should ignore {args.FullPath}: {shouldIgnoreNewFile}." + //logToAnsiConsole Colors.Verbose $"Should ignore {args.OldFullPath}: {shouldIgnoreOldFile}. Should ignore {args.FullPath}: {shouldIgnoreNewFile}." logToAnsiConsole Colors.Changed $"Delete processing is not yet implemented." if not <| shouldIgnoreNewFile then logToAnsiConsole Colors.Changed $"I saw that {args.OldFullPath} was renamed to {args.FullPath}." - logToAnsiConsole Colors.Verbose $"Should ignore {args.OldFullPath}: {shouldIgnoreOldFile}. Should ignore {args.FullPath}: {shouldIgnoreNewFile}." + //logToAnsiConsole Colors.Verbose $"Should ignore {args.OldFullPath}: {shouldIgnoreOldFile}. Should ignore {args.FullPath}: {shouldIgnoreNewFile}." filesToProcess.TryAdd(args.FullPath, ()) |> ignore let OnError (args: ErrorEventArgs) = diff --git a/src/Grace.Server/Branch.Server.fs b/src/Grace.Server/Branch.Server.fs index 9bfebce..6db1881 100644 --- a/src/Grace.Server/Branch.Server.fs +++ b/src/Grace.Server/Branch.Server.fs @@ -456,11 +456,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations 1 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -490,11 +490,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations 1 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -527,11 +527,11 @@ module Branch = context.Items.Add("ReferenceId", parameters.ReferenceId) let! result = processQuery context parameters validations 1 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -563,11 +563,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -617,11 +617,11 @@ module Branch = context.Items.Add(nameof(ReferenceType), parameters.ReferenceType) let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -653,11 +653,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -689,11 +689,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -725,11 +725,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -762,11 +762,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -798,11 +798,11 @@ module Branch = let! parameters = context |> parse let! result = processQuery context parameters validations (parameters.MaxCount) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -886,6 +886,6 @@ module Branch = return! processQuery context parameters validations 1 query with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; BranchId: {branchId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.BranchId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } diff --git a/src/Grace.Server/Repository.Server.fs b/src/Grace.Server/Repository.Server.fs index 0c6ad49..0fe9805 100644 --- a/src/Grace.Server/Repository.Server.fs +++ b/src/Grace.Server/Repository.Server.fs @@ -402,11 +402,11 @@ module Repository = let! parameters = context |> parse let! result = processQuery context parameters validations 1 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -436,11 +436,11 @@ module Repository = let! parameters = context |> parse let! result = processQuery context parameters validations 1 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -471,11 +471,11 @@ module Repository = let! parameters = context |> parse let! result = processQuery context parameters validations 1 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -511,11 +511,11 @@ module Repository = context.Items.Add("IncludeDeleted", parameters.IncludeDeleted) let! result = processQuery context parameters validations 1000 query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -543,6 +543,7 @@ module Repository = let query (context: HttpContext) (maxCount: int) (actorProxy: IRepositoryActor) = task { let referenceIds = context.Items["ReferenceIds"] :?> IEnumerable + log.LogDebug("In Repository.Server.GetReferencesByReferenceId: ReferenceIds: {referenceIds}", serialize referenceIds) return! getReferencesByReferenceId referenceIds maxCount } @@ -550,11 +551,11 @@ module Repository = context.Items.Add("ReferenceIds", parameters.ReferenceIds) let! result = processQuery context parameters validations parameters.MaxCount query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } @@ -598,10 +599,10 @@ module Repository = let! result = processQuery context parameters validations (branchIdList.Count) query let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogInformation("{CurrentInstant}: Finished {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return result with ex -> let duration_ms = (getCurrentInstant().Minus(startTime).TotalMilliseconds).ToString("F3") - log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) + log.LogError(ex, "{CurrentInstant}: Error in {path}; RepositoryId: {repositoryId}; CorrelationId: {correlationId}; Duration: {duration_ms}ms.", getCurrentInstantExtended(), context.Request.Path, graceIds.RepositoryId, (getCorrelationId context), duration_ms) return! context |> result500ServerError (GraceError.Create $"{createExceptionResponse ex}" (getCorrelationId context)) } diff --git a/src/Grace.Shared/Utilities.Shared.fs b/src/Grace.Shared/Utilities.Shared.fs index 7739260..977d17f 100644 --- a/src/Grace.Shared/Utilities.Shared.fs +++ b/src/Grace.Shared/Utilities.Shared.fs @@ -83,7 +83,7 @@ module Utilities = let logToConsole message = printfn $"{getCurrentInstantExtended()} {Environment.CurrentManagedThreadId:X2} {message}" /// Gets the first eight characters of a SHA256 hash. - let getShortenedSha256Hash (sha256Hash: String) = + let getShortSha256Hash (sha256Hash: String) = if sha256Hash.Length >= 8 then sha256Hash.Substring(0, 8) else