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 logging functions for debugging #315
Comments
Is this what you have in mind? (def p (volatile! nil))
(defn print-first-n
[n & more]
(locking p
(when (nil? @p)
(vreset! p n))
(when (pos? @p)
(vswap! p dec)
(apply print more)))) You can see it in use in this sketch: http://quil.info/sketches/show/7f7cc14db3a5ba44cb528cb7f3fd69763cabf8e53183f13bb8ba9e5a8ac35469 |
Yes, something like that. Though we can use |
Ah yes, using (defn print-first-n
[n & more]
(when (<= (q/frame-count) n)
(apply print more))) Regarding printing every n seconds, do you see an alternative to the following approach which requires storing the (def last-time (atom 0))
(defn print-every-n-millisec
[n & more]
(let [elapsed (q/millis)]
(when (< n (- elapsed last-time))
(reset! last-time elapsed)
(apply print more)))) |
Trying to think if we can avoid atom, but can't think of any approach. So probably yeah - that would be the way to do it. The only thing I mentioned before, it would be good if |
We have internal-state function for similar purposes (though doc string lies, this state should not be visible to users). |
Debugging Quil sketches is quite hard. Often you need to see state of the sketch but adding
println
to sketch causes never ending stream of text in console. Quil should provide some functionally to aid debugging. For example we could addprint-first-n
function that when called prints provided arg only the firstn
iterations. Similarly we could addprint-every-n-sec
to see samples during sketch run.The text was updated successfully, but these errors were encountered: