Fork me on GitHub
#clojure
<
2017-11-11
>
localghost01:11:31

@seancorfield i downgraded clojure to 1.8.0 and spyscope to 0.1.5. all is well with the world (since i'm not really using spec yet). once i'm done debugging i'll remove spyscope and revert to 1.9.0-RC1. thank you so much!

localghost05:11:02

is there any way to add log or println statements inside a threading macro? looks like it tries to pass the result (`nil`) to the next step. I'd like for the log/print statements to just print the message but otherwise be ignored.

seancorfield05:11:48

(-> stuff (doto (println)) more-stuff) @clojurian

bja05:11:04

@clojurian taoensso.timbre/spy can do that for you: (-> stuff spy more-stuff) if you're already using timbre

seancorfield05:11:38

(but timbre drags in half the world so unless you're already using it, perhaps a sledgehammer to crack a nut?)

seancorfield05:11:51

and I say that as someone who uses timbre in production

bja05:11:36

yeah, me too. timbre is .... blunt. but I've found it to be slightly more sane the everything else.

bja05:11:36

and if you don't have timbre, (def spy #(do (prn %) %)) gets you most of the way there

seancorfield05:11:48

@bja The big plus of timbre for me is that with plugins it can hijack all logging and filter it through one place. Otherwise, it's really a pain in the butt.

bja05:11:28

that's exactly my use case. it took me a bit of time to configure correctly, but I can manage all of my logging in the JVM world via timbre and even configure it at runtime easily

seancorfield05:11:41

We were using bare tools.logging at first and that was super fragile, with log4j, so we backed off to just println for a while, and then switched to timbre, and we're still not happy.

seancorfield05:11:11

It's like logging is just a horrible problem and timbre is the least bad of many solutions?

localghost05:11:05

@seancorfield, @bja: thank you for the suggestions. i'll look into timbre (it seems.. a lot)

localghost05:11:46

for now, i tried the doto, prn, and spy suggestions but none seem to work. here's a minimal example:

(defn foo0 [x]
  (->> x
       (* 2)))

(defn foo1 [x]
  (->> x
       (doto (println))
       (* 2)))

(defn foo2 [x]
  (->> x
       (spy "doing the thing with the thing")
       (* 2)))

seancorfield07:11:47

Use -> not ->>

seancorfield07:11:59

->> inserts the expression at the end of the form. You want the expression inserted as the first argument, not the last.

localghost05:11:19

the function call immediately after the log statement fails with either a cast or arity error.

madstap07:11:10

It's for exploring at the repl and not a logging library though

madstap07:11:26

(require '[hugin.dbg :as dbg])
(defn foo [x]
  (->> x
       (dbg/p< "Doing the thing with the thing")
       (* 2)))
should work.

roti13:11:39

hmm, dissoc does not work on vectors. what's the simplest way to remove an element from a vector (by index)?

lmergen16:11:05

hmmm, i think i broke my repl environment, but i have no idea how to debug it. when refreshing, it throws exceptions on the (:require ...) statements of some files that it cannot find certain modules, where they clearly are defined. after some fierce debugging i was able to get things refreshing, but now my webserver's handlers are suddenly undefined (getting "java.lang.IllegalStateException: Attempting to call unbound fn:" errors) i think something is very wrong somewhere, but i'm unable to pinpoint the issue. sounds like some dangling references / things not getting properly refreshed. any suggestions ?

lmergen16:11:55

it's worth noting that lein run and the uberjar created with lein uberjar run fine

lmergen16:11:07

so i think there's definitely something wrong with my reloaded flow somewhere

danielstockton19:11:42

How best to loop over some data and assert it's valid? I tried putting asserts in a doseq but getting strange results: when there is an exception, that iteration is not called.

seancorfield19:11:03

@danielstockton can you expand a bit on what you're trying to do? Perhaps share some code?

danielstockton20:11:49

Sure, let me try and come up with a minimum repro

danielstockton20:11:20

Nevermind, I can't reproduce. I'm basically doing:

(doseq [i [1 2 3 4 5]]
  (println i)
  (assert (< i 4) "Too big!"))
but with something more complicated.

danielstockton20:11:29

Error is being swallowed somewhere else probably.

danielstockton20:11:57

Open to hearing about any better patterns for this sort of thing.

rwilson22:11:23

Does anybody have experience using Akka via okku? The design looks ok, documentation decent, and it shows up in a "Clojure Programming Cookbook", but the original author admits in a PR comment that it was more of a proof of concept and that he never really used it (as of 2015, at least).