#clojure logs

2015-02-13

18:14rhg135edit the output of (into {} (for [[s v] (ns-publics 'clojure.core)] [s (deref v)]))
18:14justin_smiththat's one way to do it, heh
18:29nicferrieranyone know about logging?
18:29justin_smithnicferrier: timbre makes it pretty easy
18:29nicferrierI'd like to alter the format of my logging messages... seems to be less popular than in java
18:30nicferrierjustin_smith: I guess I'll look. I'm a bit worried about dependencies...
18:30justin_smiththe deps list on timbre is really small
18:31justin_smithanyway, you can also use properties files or xml and use the standard java logging config
18:31justin_smithbut timbre is much more clojure-friendly
18:32nicferriertimbre does look good. I didn't mean I was worried about timbre's deps. but about me adding deps.
18:33nicferrierI am inside a regulated environment where they regulate the software we use.
18:33nicferrierwhich means I have to have every tiny bit of code I use approved.
18:33nicferrierwhich means I am sad and angry a lot of the time.
18:33justin_smithoh, I can imagine
19:28raspasovdoes anyone know if using (apply + [1 2 3]) has a performance overhead compared to pure (+ 1 2 3)
19:28raspasov?
19:29justin_smithraspasov: check out the source for +
19:29hiredmanyes
19:29raspasovjustin_smith: I'm talking about any IFn in general, not only +
19:29raspasovi.e. is the performance overheard "just" the creation of the vector, or there's more?
19:30justin_smithraspasov: different functions handle multiple args differently, but apply by itself does not have a very large overhead
19:30raspasovjustin_smith: ok, thanks, I guess I should benchmark (as always) lol
19:31justin_smithyeah, can't hurt to throw your code at criterium/bench
19:31cddrnicferrier: Congrats on sneaking clojure into that environment
19:32nicferriercddr: thanks.
19:32nicferrierwe are sneaking too.
19:36nicferrierstill not many examples of how to configure a log instance with timbre
19:36nicferrierlots on the logging config... nothing on how to do it.
19:37justin_smithnicferrier: timbre/set-config!
19:37nicferrieryeah... but I want to change the format of the logger. no example.
19:37justin_smithand that config ends up altering the behavior of logging
19:37justin_smithit's a single global atom
19:37nicferrierthis is a stackoverflow world. I need to cut and paste.
19:37nicferrier:-)
19:37justin_smithhaha
19:39nicferriergotta crash now anyway. too tired to work it out.
20:05raspasovjust saw this for the first time: java.lang.IllegalArgumentException: fns taking primitives support only 4 or fewer args
20:05raspasovany idea why that is? :)
20:06justin_smithraspasov: combinatorial explosion of required declarations in the java source
20:06justin_smithso you are limited to 4
20:06raspasovmakes sense :)
20:18justin_smithraspasov: you can see something similar for java methods that support primitives - each combo of primitives must be a separate method declaration
20:19raspasovjustin_smith: thanks
22:11vasso 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:12justin_smithvas: you are refreshing the pages but not seeing the new content?
22:13vastruth
22:13ianhedoesitdo you have any errors in the program?
22:13justin_smithvas: how do you start the ring server?
22:14vasjustin_smith: lein ring server-headless
22:14justin_smithvas: typically what is needed is to use #'handler instead of handler as the argument passed to the ring server on startup
22:14vasjustin_smith: interesting. i've seen that in some source but didn't know what it was for.
22:14vasianhedoesit: i love your question, but i'm afraid i can't answer it. xD
22:14justin_smithvas: but this won't matter if you are using lein-ring
22:15justin_smithvas usually lein-ring server will automatically put everything inside a wrap-reload
22:15vaseverything 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:16vasyeah, 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:16justin_smithvas: so you are directly serving the html, and not rendering it from the handler functions?
22:17vasjustin_smith: both. using enlive to sexify the template html.
22:18justin_smithvas: 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:18justin_smithare you re-reading the templates, or loading them once?
22:18vasinterestingly: the enlive tranforms always appear up-to-date, but the template html does not.
22:19justin_smithvas: are you reloading the template file on each run, or are they captured in eg. a top level def?
22:19amalloyyeah, i'd bet like $20 justin_smith is on the right track here
22:20vasjustin_smith: they're in a top level def. *gives $20* ...
22:20vashow would i make it so that they get reloaded automagically ? o.o
22:20justin_smithvas: tell wrap-reload to watch those files
22:20justin_smithuse a function that memoizes, but reloads them if they change modification date
22:21justin_smithunconditionally reload them on every request under dev profile
22:21justin_smithyou have a few options
22:22vasjustin_smith: super cool! thank you.
22:23vasso I can just give wrap-reload a directory to watch?
22:24vashttps://github.com/ring-clojure/ring/blob/8927e9b3f556874720321078c85a62fcf9a23f1b/ring-devel/src/ring/middleware/reload.clj
22:24justin_smithvas: as I mentioned, wrap-reload is in there by default
22:24justin_smithbut I think there is a way to give it parameters when using lein ring
22:24vasAha.
22:25justin_smithvas: https://github.com/weavejester/lein-ring#web-server-options
22:25justin_smithyou want to set :reload-paths
22:27vashrm. seems like the behavior i'm wanting is the default. some detective work to do
22:27justin_smiththe html files are in your classpath?
22:29vasi think so. they are all in the /resources dir how would i verify what my classpath encompasses?
22:30justin_smithyeah, resources is usually on the classpath (via resource-path)
22:30justin_smithit could also be that wrap-reload isn't watching all filetypes?
22:31justin_smiththe docs say it only defaults to ["src"]
22:31justin_smithhttps://ring-clojure.github.io/ring/ring.middleware.reload.html
22:31justin_smithtry providing ["src" "resources"] for a lark, see if that helps
22:39vasjustin_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:41justin_smithvas: lein ring server was already using wrap-reload
22:41justin_smithor did you turn it off on the project.clj?
22:41vasna 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:42justin_smithvas: look at the docs I linked above in that github readme
22:42justin_smithyou can specify the args there
22:43justin_smithyou 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:43TEttinger(inc justin_smith)
22:43lazybot⇒ 186
22:46vasjustin_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:46justin_smithvas: it's an option you provide inside project.clj
22:46vasOhhh. cool.
22:47justin_smithvas: so in project.clj: :ring {:reload-paths ["src" "resources"]}
22:48justin_smith}
22:48justin_smitherr wait that wasn't even needed