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

DX improvements and more info in logs #93

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Nov 27, 2024

In trying to help a customer with a question they had, p1731493061054529-slack-C0533SEJ82H, I wanted to look into the logs from the demo app.

In the meantime I noticed a few things the project could use:

@mokagio mokagio changed the title DX improvements DX improvements and more info in logs Nov 28, 2024
This way, we avoid other `os_log` calls getting in between `os_log` and
`dump` and breaking the association between the two which makes the logs
harder to understand.
@mokagio mokagio marked this pull request as ready for review November 28, 2024 00:56
Comment on lines +6 to +7
excluded:
- .build
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ought to go in the the remote config, too.

private func os_log_sending_event(_ event: Event, log: OSLog = .tracker, type: OSLogType = .debug) {
var eventDump = DumpOutput()
dump(event.toDict(), to: &eventDump)
os_log("Sending an event from Track:\n%@", log: log, type: type, eventDump.content)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Revisit the os_log implementation and consider using modern Logger, see Create a Log Object to Organize Messages, which supports string interpolation.

-scheme ParselyDemo \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=$(SIMULATOR_NAME),OS=$(SIMULATOR_OS)' \
| xcpretty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this new syntax with the set -o pipefail in the Make task is still valid in CI:

image

See #95

@mokagio mokagio requested a review from a team November 28, 2024 06:26
mutating func write(_ string: String) {
content.append(string)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this type is needed.

$ swift repl
Welcome to Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4).
Type :help for assistance.
  1> var content = ""
content: String = ""
  2> dump([1:2], to: &content)
$R0: [Int : Int] = 1 key/value pair {
  [0] = {
    key = 1
    value = 2
  }
}
  3> print(content)
▿ 1 key/value pair
  ▿ (2 elements)
    - key: 1
    - value: 2

Copy link
Contributor Author

@mokagio mokagio Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, 06c8b36 Thanks!

@mokagio mokagio requested a review from crazytonyli January 3, 2025 19:30

# Convenience to open the lib and demo project with Xcode, given it's not in the root.
open:
open -a $(XCODE_PATH) ./Demo/ParselyDemo.xcodeproj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an advantage to using this method over xed?

@@ -82,3 +81,10 @@ class Track {
videoManager.sendHeartbeats()
}
}

/// Utitlity to log sending event with a dump of the event.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Utitlity to log sending event with a dump of the event.
/// Utility to log sending event with a dump of the event.

Copy link

@twstokes twstokes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @mokagio! 🚀 I made a couple small comments, nothing that blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants