-
Notifications
You must be signed in to change notification settings - Fork 10
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
Need examples of Action.warn etc. #3
Comments
Hey Tom, thanks for your interest! You're spot on. For intermediate results, I am generally adding to the Action data map. Otherwise, I create new Actions (nested actions are fine). Actions keep a reference to their parent, though this is contingent on your concurrency model, I have only really leveraged that for indentation. Warnings have not been fully fleshed out, and I wouldn't recommend them for successful intermediate results anyways. A while back I looked at supporting multiple Action completions, but decided that a single completion had more useful semantics, especially since Actions can be nested. Have you considered a single-line action? Something like:
Compared to the built-in logging expressions, it's a bit noisier, but it's also a lot more structured. |
Thanks for the extra details @mahmoud. I agree, you don't want multiple completions, that doesn't really make sense. Nesting using a single-line action produces clean enough code that I'd be happy with, but I'm using a variant of the
And now I get:
It would be very instructive to see how you'd refactor some real-world code that has fairly extensive usage of |
Sure! So, for sure this is one of the most immediate friction points one would hit, especially coming from There are two approaches I use:
You can see the first approach in action in Chert. Note the separate complete format (
I'm not super happy about the How's that sounding? |
Yes, that's pretty good, thanks. Real-world example code is always helpful. Agreed re It seems to me there's room for lithoxyl to get a bit more opinionated about the "sensible" setup too - e.g. with a couple of pre-built sinks for stderr, syslog etc. that can be added to a Logger with a line or two of code to reduce the friction when getting started. I had a question on StackOverflow about creating an emitter that outputs to the logging module, similar to the SyslogEmitter, that may fit into that pre-rolled sink category too. |
I'm trying to refactor some code that uses the standard
logging.getLogger
to uselithoxyl
and I'm a bit stuck without some more examples comparing the old style with the new.In particular, how should I go about converting code that looks like:
Logging the start/finish is fine, but I'm stuck on the "right" way to log the intermediate results. Should they just be assigned to Action's data:
That feels a bit clunky as the resulting
repr
of the data in the log line is pretty unreadable and out of order.Or can
warn
be used? It doesn't seem quite like it does what I want as it has a different level than theAction
and it's not outputting how I would expect.The text was updated successfully, but these errors were encountered: