[Feature Enhancement]: Complete Logging Implementation
@stoicswe is already working on this.
Since May 24, 2024.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- swift
- Domain
- backend-api-design
Research direction
Read the package areas for ATProtoKit, ATProtoTools, and ATProtoAdmin, then inspect the applyWrites() example in the issue as a guide to the requested logging points. Add logging across all three classes, including session and request failures and outcomes; completion means all three checklist items are covered. A linked pull request was merged, so check its changes and the current code before taking this on.
Written by the indexing model from the issue text.
Description
Summary
No response
Pain points
The current implementation of ATProtoKit lacks a centralized logging mechanism, leading to several challenges, namely that debugging is much more difficult to deal with.
To solve this, SwiftLog will be integrated into the package. Furthermore, two logging backend implementations will be used: one that maps to Apple's unified Logger framework (for Apple platforms) and one that maps to the standard SwiftLog logger.
To be more specific, log events for the methods should be added as appropriate. As an example, take a look at applyWrites():
public func applyWrites(_ repositoryDID: String,
shouldValidate: Bool? = true,
writes: [ApplyWritesUnion],
swapCommit: String?) async throws {
guard session != nil,
let accessToken = session?.accessToken else {
throw ATRequestPrepareError.missingActiveSession
}
guard let sessionURL = session?.pdsURL,
let requestURL = URL(string: "\(sessionURL)/xrpc/com.atproto.repo.applyWrites") else {
throw ATRequestPrepareError.invalidRequestURL
}
let requestBody = RepoApplyWrites(
repositoryDID: repositoryDID,
shouldValidate: shouldValidate,
writes: writes,
swapCommit: swapCommit
)
do {
let request = APIClientService.createRequest(forRequest: requestURL,
andMethod: .post,
acceptValue: nil,
contentTypeValue: "application/json",
authorizationValue: "Bearer \(accessToken)")
try await APIClientService.sendRequest(request,
withEncodingBody: requestBody)
} catch {
throw error
}
}
Various places within the method can have log events, including:
- Within the first
guardstatement'selseblock, stating thatsessionoraccessTokendoesn't have a value. - After the
guardstatement which would show the value ofaccessToken(albeit, obfuscated). - Within the second
guardstatement'selseblock, stating that there's an invalid request URL, followed by aString(describing:)of the request URL. - After the
guardstatement, which would show the value ofrequestURL. - After
requestBody, which would show the values ofrequestBody. - After
request, which would show the value ofrequest. - After the
try awaitcode, which would say that the request has been successful. - Within the
catchblock, which gives an error log, followed by displaying the error itself.
This issue will focus on implementing log events to the ATProtoKit, ATProtoTools, and ATProtoAdmin classes. Future updates will deal with the remaining parts of the Swift package.
Considered Alternatives
No response
Is this a breaking change?
Yes
Additional Context
- Implement log events on all parts of the
ATProtoKitclass. - Implement log events on all parts of the
ATProtoAdminclass. - Implement log events on all parts of the
ATProtoToolsclass.
- Dominant language
- Swift
- Stars
- 226
- Forks
- 40
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MasterJ93/ATProtoKit
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
MasterJ93/ATProtoKit#354 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MasterJ93/ATProtoKit#352 ·
-
[Feature Enhancement]: Add `sort` parameter to `getQuotes`Possibly taken A pull request linked to this issue is open or already merged. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MasterJ93/ATProtoKit#346 · 1 comment ·
-
[Feature Request]: Add `app.bsky.actor.contentVisibilityDeclaration` record supportPossibly taken A pull request linked to this issue is open or already merged. Opennew feature
Difficulty 3/5 1-2 days Newbie friendliness 68/100
MasterJ93/ATProtoKit#350 · 4 comments ·
-
[Feature Enhancement]: Support scoped mutes (`onlyReposts` / `onlyQuoteposts`) in `muteActor`Possibly taken A pull request linked to this issue is open or already merged. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
MasterJ93/ATProtoKit#348 · 1 comment ·
All issues in MasterJ93/ATProtoKit
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
good first issue help wanted testing
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area:cli documentation good first issue priority:low
Difficulty 1/5 Under an hour Newbie friendliness 94/100
isaaclins/freesnitch#430 ·
Maintainers usually reply within 1 day
-
enhancement help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
heysidhant/appvanish#4 ·
-
bug priority:low status:queued
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day