Skip to content

Commit

Permalink
chore(commitService): add logging (#1211)
Browse files Browse the repository at this point in the history
## Problem

we lack observability here. we experienced a silent failure in terms of divergence, and not a clue on how to debug since we cannot replicate this + no unusual errors around that time. 
this is a last ditch effort to see if we can get more info on this issue, but personally am not too optimistic about this pr since by right the top level handlers should log errors
  • Loading branch information
kishore03109 authored Mar 14, 2024
1 parent f1370fa commit 4f09c6c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/services/db/GitFileCommitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ export default class GitFileCommitService {
}

if (stagingCreateResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingCreateResult.error} when creating commit to staging for ${sessionData.siteName} for file ${fileName} in directory ${directoryName}`
)
throw stagingCreateResult.error
} else if (
shouldUpdateStagingLite &&
stagingLiteCreateResult &&
stagingLiteCreateResult.isErr()
) {
logger.error(
`CommitServiceError: ${stagingLiteCreateResult.error} when creating commit to staging-lite for ${sessionData.siteName} for file ${fileName} in directory ${directoryName}`
)
throw stagingLiteCreateResult.error
}

Expand Down Expand Up @@ -140,12 +146,18 @@ export default class GitFileCommitService {
}

if (stagingUpdateResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingUpdateResult.error} when updating in staging for ${sessionData.siteName} for file ${fileName} in directory ${directoryName}`
)
throw stagingUpdateResult.error
} else if (
shouldUpdateStagingLite &&
stagingLiteUpdateResult &&
stagingLiteUpdateResult.isErr()
) {
logger.error(
`CommitServiceError: ${stagingLiteUpdateResult.error} when updating to staging-lite for ${sessionData.siteName} for file ${fileName} in directory ${directoryName}`
)
throw stagingLiteUpdateResult.error
}

Expand Down Expand Up @@ -190,12 +202,18 @@ export default class GitFileCommitService {
}

if (stagingDeleteResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingDeleteResult.error} when deleting in staging for ${sessionData.siteName} for directory ${directoryName}`
)
throw stagingDeleteResult.error
} else if (
shouldUpdateStagingLite &&
stagingLiteDeleteResult &&
stagingLiteDeleteResult.isErr()
) {
logger.error(
`CommitServiceError: ${stagingLiteDeleteResult.error} when deleting in staging-lite for ${sessionData.siteName} for directory ${directoryName}`
)
throw stagingLiteDeleteResult.error
}

Expand Down Expand Up @@ -246,12 +264,18 @@ export default class GitFileCommitService {
}

if (stagingDeleteResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingDeleteResult.error} when deleting in staging for ${sessionData.siteName} for file ${fileName} in directory ${directoryName}`
)
throw stagingDeleteResult.error
} else if (
shouldUpdateStagingLite &&
stagingLiteDeleteResult &&
stagingLiteDeleteResult.isErr()
) {
logger.error(
`CommitServiceError: ${stagingLiteDeleteResult.error} when deleting in staging-lite for ${sessionData.siteName} for file ${fileName} in directory ${directoryName}`
)
throw stagingLiteDeleteResult.error
}

Expand Down Expand Up @@ -289,12 +313,18 @@ export default class GitFileCommitService {
}

if (stagingDeleteResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingDeleteResult.error} when deleting in staging for ${sessionData.siteName} for multiple files ${items}`
)
throw stagingDeleteResult.error
} else if (
shouldUpdateStagingLite &&
stagingLiteDeleteResult &&
stagingLiteDeleteResult.isErr()
) {
logger.error(
`CommitServiceError: ${stagingLiteDeleteResult.error} when deleting in staging-lite for ${sessionData.siteName} for multiple files ${items}`
)
throw stagingLiteDeleteResult.error
}

Expand All @@ -321,6 +351,9 @@ export default class GitFileCommitService {
)

if (stagingRenameResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingRenameResult.error} when renaming in staging for ${sessionData.siteName} for directory ${oldPath} to ${newPath}`
)
throw stagingRenameResult.error
}

Expand All @@ -338,6 +371,9 @@ export default class GitFileCommitService {
message
)
if (stagingLiteRenameResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingLiteRenameResult.error} when renaming in staging-lite for ${sessionData.siteName} for directory ${oldPath} to ${newPath}`
)
throw stagingLiteRenameResult.error
}
}
Expand Down Expand Up @@ -366,6 +402,9 @@ export default class GitFileCommitService {
message
)
if (stagingMvFilesResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingMvFilesResult.error} when moving in staging for ${sessionData.siteName} for directory ${oldPath} to ${newPath}`
)
throw stagingMvFilesResult.error
}

Expand All @@ -384,6 +423,9 @@ export default class GitFileCommitService {
message
)
if (stagingLiteMvFilesResult.isErr()) {
logger.error(
`CommitServiceError: ${stagingLiteMvFilesResult.error} when moving in staging-lite for ${sessionData.siteName} for directory ${oldPath} to ${newPath}`
)
throw stagingLiteMvFilesResult.error
}
}
Expand Down

0 comments on commit 4f09c6c

Please sign in to comment.