#clojure log - Feb 13 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

18:14 rhg135: edit the output of (into {} (for [[s v] (ns-publics 'clojure.core)] [s (deref v)]))

18:14 justin_smith: that's one way to do it, heh

18:29 nicferrier: anyone know about logging?

18:29 justin_smith: nicferrier: timbre makes it pretty easy

18:29 nicferrier: I'd like to alter the format of my logging messages... seems to be less popular than in java

18:30 justin_smith: I guess I'll look. I'm a bit worried about dependencies...

18:30 justin_smith: the deps list on timbre is really small

18:31 anyway, you can also use properties files or xml and use the standard java logging config

18:31 but timbre is much more clojure-friendly

18:32 nicferrier: timbre does look good. I didn't mean I was worried about timbre's deps. but about me adding deps.

18:33 I am inside a regulated environment where they regulate the software we use.

18:33 which means I have to have every tiny bit of code I use approved.

18:33 which means I am sad and angry a lot of the time.

18:33 justin_smith: oh, I can imagine

19:28 raspasov: does anyone know if using (apply + [1 2 3]) has a performance overhead compared to pure (+ 1 2 3)

19:28 ?

19:29 justin_smith: raspasov: check out the source for +

19:29 hiredman: yes

19:29 raspasov: justin_smith: I'm talking about any IFn in general, not only +

19:29 i.e. is the performance overheard "just" the creation of the vector, or there's more?

19:30 justin_smith: raspasov: different functions handle multiple args differently, but apply by itself does not have a very large overhead

19:30 raspasov: justin_smith: ok, thanks, I guess I should benchmark (as always) lol

19:31 justin_smith: yeah, can't hurt to throw your code at criterium/bench

19:31 cddr: nicferrier: Congrats on sneaking clojure into that environment

19:32 nicferrier: cddr: thanks.

19:32 we are sneaking too.

19:36 still not many examples of how to configure a log instance with timbre

19:36 lots on the logging config... nothing on how to do it.

19:37 justin_smith: nicferrier: timbre/set-config!

19:37 nicferrier: yeah... but I want to change the format of the logger. no example.

19:37 justin_smith: and that config ends up altering the behavior of logging

19:37 it's a single global atom

19:37 nicferrier: this is a stackoverflow world. I need to cut and paste.

19:37 :-)

19:37 justin_smith: haha

19:39 nicferrier: gotta crash now anyway. too tired to work it out.

20:05 raspasov: just saw this for the first time: java.lang.IllegalArgumentException: fns taking primitives support only 4 or fewer args

20:05 any idea why that is? :)

20:06 justin_smith: raspasov: combinatorial explosion of required declarations in the java source

20:06 so you are limited to 4

20:06 raspasov: makes sense :)

20:18 justin_smith: raspasov: you can see something similar for java methods that support primitives - each combo of primitives must be a separate method declaration

20:19 raspasov: justin_smith: thanks

22:11 vas: so I have been working on an app using compojure and ring and it's going pretty well, but every time I change an HTML file it seems like I must restart my server. Or do these automagically refresh and it's just the browser at fault?

22:12 justin_smith: vas: you are refreshing the pages but not seeing the new content?

22:13 vas: truth

22:13 ianhedoesit: do you have any errors in the program?

22:13 justin_smith: vas: how do you start the ring server?

22:14 vas: justin_smith: lein ring server-headless

22:14 justin_smith: vas: typically what is needed is to use #'handler instead of handler as the argument passed to the ring server on startup

22:14 vas: justin_smith: interesting. i've seen that in some source but didn't know what it was for.

22:14 ianhedoesit: i love your question, but i'm afraid i can't answer it. xD

22:14 justin_smith: vas: but this won't matter if you are using lein-ring

22:15 vas usually lein-ring server will automatically put everything inside a wrap-reload

22:15 vas: everything compiles fine, it's just that when I edit an html file, save it, and refresh the page, i don't see the changes. but now it seems more likely that it is firefox just caching things even when i have it set to not do that

22:16 yeah, i was wondering if wrap-reload would be the solution. if lein does that already then awesome. it's not a big deal, just a minor glitch in the matrix of workflow

22:16 justin_smith: vas: so you are directly serving the html, and not rendering it from the handler functions?

22:17 vas: justin_smith: both. using enlive to sexify the template html.

22:18 justin_smith: vas: wrap-reload will be smart enough to redef things if your source files change, but it may not be able to automatically update things if your templates change

22:18 are you re-reading the templates, or loading them once?

22:18 vas: interestingly: the enlive tranforms always appear up-to-date, but the template html does not.

22:19 justin_smith: vas: are you reloading the template file on each run, or are they captured in eg. a top level def?

22:19 amalloy: yeah, i'd bet like $20 justin_smith is on the right track here

22:20 vas: justin_smith: they're in a top level def. *gives $20* ...

22:20 how would i make it so that they get reloaded automagically ? o.o

22:20 justin_smith: vas: tell wrap-reload to watch those files

22:20 use a function that memoizes, but reloads them if they change modification date

22:21 unconditionally reload them on every request under dev profile

22:21 you have a few options

22:22 vas: justin_smith: super cool! thank you.

22:23 so I can just give wrap-reload a directory to watch?

22:24 https://github.com/ring-clojure/ring/blob/8927e9b3f556874720321078c85a62fcf9a23f1b/ring-devel/src/ring/middleware/reload.clj

22:24 justin_smith: vas: as I mentioned, wrap-reload is in there by default

22:24 but I think there is a way to give it parameters when using lein ring

22:24 vas: Aha.

22:25 justin_smith: vas: https://github.com/weavejester/lein-ring#web-server-options

22:25 you want to set :reload-paths

22:27 vas: hrm. seems like the behavior i'm wanting is the default. some detective work to do

22:27 justin_smith: the html files are in your classpath?

22:29 vas: i think so. they are all in the /resources dir how would i verify what my classpath encompasses?

22:30 justin_smith: yeah, resources is usually on the classpath (via resource-path)

22:30 it could also be that wrap-reload isn't watching all filetypes?

22:31 the docs say it only defaults to ["src"]

22:31 https://ring-clojure.github.io/ring/ring.middleware.reload.html

22:31 try providing ["src" "resources"] for a lark, see if that helps

22:39 vas: justin_smith: so I added wrap-reload ["src" "resources"] to my def app -> thread-through, restarted my lein server, and attempted to add a simple <span> element to one of the html source files to see what would happen... no dice

22:41 justin_smith: vas: lein ring server was already using wrap-reload

22:41 or did you turn it off on the project.clj?

22:41 vas: na i didn't turn it off. but you are saying that i should just pass those arguments to the lein invocation on the command line somehow?

22:42 justin_smith: vas: look at the docs I linked above in that github readme

22:42 you can specify the args there

22:43 you don't want wrap-reload in your app's source, because it's only useful during dev and shouldn't be present in production

22:43 * TEttinger glances at the backlog

22:43 TEttinger: (inc justin_smith)

22:43 lazybot: ⇒ 186

22:46 vas: justin_smith: thanks. i am not sure what it looks like to pass leiningen different args from the command line, but i guess i have some learning to do :]

22:46 justin_smith: vas: it's an option you provide inside project.clj

22:46 vas: Ohhh. cool.

22:47 justin_smith: vas: so in project.clj: :ring {:reload-paths ["src" "resources"]}

22:48 }

22:48 err wait that wasn't even needed

Logging service provided by n01se.net