-
Notifications
You must be signed in to change notification settings - Fork 4
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
allow setting the logVerbosity of Documents created within the repo #118
allow setting the logVerbosity of Documents created within the repo #118
Conversation
No qualms with where you're going - I haven't needed the logging for debugging (which is mostly where I use it) at the Document level outside of the repo, but totally game to enable it. What do you think about making another "component" for the logger, including in that private dictionary, and going from there? The public var makes it look more like you can "turn it on and off", where in practice its not nearly as configurable (enable at start or not), although I've been mostly using it only in tests (unit, functional, or interop/integration) when something was confusing to me - to debug. Is part of the goal here to make it more dynamically configurable? |
We were debugging some timing issue and tried to crank up all logging to "eleven" to see what's going on. We only later found that compared to the
Yeah, I went that way initially but found adding a LogComponent also requires to return a
Yeah - agreed, it only works for documents loaded after setting.
Nope, not at all. It was all just for local debugging. With that all in mind, few ideas/options:
WDYT? |
The last option (passing a default logger of .errorOnly) matches the behavior of an Automerge document currently, but makes it explicit rather than implicit. For the Document itself, there's little logging because there's little logic to log from - 99% if the logic there is all in the Rust library, which isn't as easily exposed to these sorts of mechanisms - and currently doesn't log. The places in Automerge-swift where I did lean into logging was in the Encoding and Decoding logic for the Codable support, so more specifically the AutomergeEncoder and AutomergeDecoder classes. I personally found the deluge of logging data when I had everything enabled to be "too much" - I was swimming in log lines that obscured anything else I was looking for, which is why I went to the trouble to add the explicit logLevels and the hilariously wonky coding to keep the oslog() privacy mechanisms that are bound into the compiler. (I found it really, really annoying that I couldn't wrap or extend that, but with the compiler code generation bits, it just didn't fly) |
`LogVerbosity` on automerge's Documents are internal and can only be specified on document creation. This PR allows setting the default for this via the repository. Note: first approach was to add a case in `LogComponent`, though that _also_ needs a logger. Given we don't really want to log into the `Document`'s logger from the `Repo`, it felt better to add a separate public variable.
while `DocumentStorage` has it's own logLevel, we didn't push this into the Documents created from it. This adds another log level and forwards it from the repo.
920378d
to
0d665c5
Compare
Rebase on current |
LogVerbosity
on automerge'sDocument
is internal and can only be specified on document creation.This PR allows setting the default for this via the repository.
Note: My first approach was to add a case in
LogComponent
, though that also needs a logger. Given we don't really want to log into theDocument
's logger from theRepo
, it felt better to add a separate public variable. Happy to adjust though!