-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
Add configurability to logging and other bits #43
Conversation
Actually the arglists stuff in |
@lorddoig Thankyou for this upgrade. It might be a week before I get to review this. But, yes, this is an area that needs to be improved. |
@lorddoig Okay I'm back on this. There appears to be 3 parts in this patch:
Regarding point 1 - you say to ignore. So that leaves point 2. I'm open to that change, but want to be sure I understand your motivations. Are you using figwheel? Is it figwheel file reloads which cause the warnings about re-loaded handlers that you mention? |
On another note - I really like re-frame and using it pretty heavily has led to some other thoughts (this is all subjective and sorry to hijack the issue, can open a separate one if you agree with any of the following):
With regard to these points I think there's perhaps a case for making a few macros that covers some of them (e.g. (defmulti handle (fn [_ _ meta] (:id meta)))
(defmethod handle :set-thing
[db ?data {:keys [id]}]
(assoc db :thing (do-something ?data))
(re-frame.core/set-handler! handle) Putting all stuff not immediately pertinent to the domain problem in a map as the last arg seems a friendly and extensible solution. This doesn't play so nice with middleware as it is now, but with regard to point 3 - what if middleware could be applied in the function body with a Thoughts? Feel free to call me out on any of this and tell me I'm doing it wrong. |
@lorddoig I agree with all the other pain points you raise. I will cycle back to here in a week or so and trigger a further discussion on these issues. I've got a couple of other things to get right first. |
Will this change satisfy your logging needs? This change will be a part of v0.4.0 |
Yup that makes sense. Just a couple of things. With respect to (binding [re-frame.core/*log-fn* (fn [& _] (comment "Noop"))]
(dispatch [:something-expected-to-be-noisy])) ? I'm not sure how dynamic vars work in the face of the kind of single-threaded asynchronicity we have here though, so maybe not. It's not so pertinent but I still worry about |
@lorddoig You should now be able to any of this:
After all, you can now swap in whatever logging functions you want. These functions you provide might allow a "mute" variable to be dynamically bound to true, or they might allow you to use good.debug, that's up to you. |
I have transferred your 2nd-ary notes above to a separate ticket #56 for further discussion. But, in the meantime, do you feel the original 3 issues raised here are now handled, and can this issue be closed? |
There's a few things here, but the main thing is logging so feel free to cherry pick.
I added the logging stuff because the console was drowning in messages about overwritten re-frame handlers every time I changed a file; it's very lightweight as you can see. I removed the console grouping stuff, as all console calls between
group()
andgroupEnd()
are gobbled up, whether generated by re-frame or not. It's also not a standard and will blow up on, for example, IE versions older than 11.