Re: Print only by clojure code
Hi Tassilo, i tried your macro and its work perfectly, thank you. On 9 Feb, 01:57, Tassilo Horn tass...@member.fsf.org wrote: Cedric Greevey cgree...@gmail.com writes: Hi Cedric, Just in case the java lib in fact uses System.out/err directly, one can redirect standard out and error to something else. (with-open [w (clojure.java.io/writer /dev/null)] (binding [*out* w, *err* w] (.noisyJavaCall1 1 2 3) (.noisyJavaCall2 3 2 1))) Of course, /dev/null is somewhat platform specific. Will that work? I was under the impession that binding *out* and *err* had no effect on System/out or System/err. No, it won't work. I tested it briefly in a slime repl and forgot the fact that java sysouts aren't printed in there anyway. So using your setOut/Err() advice, here's a java quitening macro that actually works: --8---cut here---start-8--- (defmacro without-java-output [ body] `(with-open [w# (java.io.PrintStream. /dev/null)] (let [oo# System/out, oe# System/err] (System/setOut w#) (System/setErr w#) (try ~@body (finally (System/setOut oo#) (System/setErr oe#)) (without-java-output (.println System/out Hello out) (.println System/err Hello err)) --8---cut here---end---8--- Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
Hi Tassilo, i tried your macro and its work perfectly, thank you. On 9 Feb, 01:57, Tassilo Horn tass...@member.fsf.org wrote: Cedric Greevey cgree...@gmail.com writes: Hi Cedric, Just in case the java lib in fact uses System.out/err directly, one can redirect standard out and error to something else. (with-open [w (clojure.java.io/writer /dev/null)] (binding [*out* w, *err* w] (.noisyJavaCall1 1 2 3) (.noisyJavaCall2 3 2 1))) Of course, /dev/null is somewhat platform specific. Will that work? I was under the impession that binding *out* and *err* had no effect on System/out or System/err. No, it won't work. I tested it briefly in a slime repl and forgot the fact that java sysouts aren't printed in there anyway. So using your setOut/Err() advice, here's a java quitening macro that actually works: --8---cut here---start-8--- (defmacro without-java-output [ body] `(with-open [w# (java.io.PrintStream. /dev/null)] (let [oo# System/out, oe# System/err] (System/setOut w#) (System/setErr w#) (try ~@body (finally (System/setOut oo#) (System/setErr oe#)) (without-java-output (.println System/out Hello out) (.println System/err Hello err)) --8---cut here---end---8--- Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Print only by clojure code
Hi guys, I have developed a very very little application in clojure that use an external lib in java that i prefer do not touch. The problem is that this lib for some weird reason (debug i guess) print at video a bunch of information useless for me, there is any way to avoid this problem, i mean can i just print what the clojure code actually print and not what also the lib in java print ? I'm sorry for my English... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
It's logging, and assuming the logging implementation it is using log4j, you can specify the logging properties in a properties file, as system properties, or set the properties in code. The easiest way is to place a file called log4j.properties on the classpath (in the resources directory of your project) containing the following: # set root logger level to OFF (OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL) log4j.rootLogger=OFF On Wed, Feb 8, 2012 at 1:49 PM, Simone Mosciatti mweb@gmail.com wrote: Hi guys, I have developed a very very little application in clojure that use an external lib in java that i prefer do not touch. The problem is that this lib for some weird reason (debug i guess) print at video a bunch of information useless for me, there is any way to avoid this problem, i mean can i just print what the clojure code actually print and not what also the lib in java print ? I'm sorry for my English... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
Piggy-backing off Mark's answer, if it is log4j that's being used, you can also use log4j.properties to set different logging levels for your Java code vs. your Clojure code (assuming the code are in different packages): http://stackoverflow.com/questions/3569395/filtering-out-log4j-messages-from-third-party-frameworks On Wednesday, February 8, 2012 11:40:45 AM UTC-8, Mark Rathwell wrote: It's logging, and assuming the logging implementation it is using log4j, you can specify the logging properties in a properties file, as system properties, or set the properties in code. The easiest way is to place a file called log4j.properties on the classpath (in the resources directory of your project) containing the following: # set root logger level to OFF (OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL) log4j.rootLogger=OFF On Wed, Feb 8, 2012 at 1:49 PM, Simone Mosciatti mweb@gmail.com wrote: Hi guys, I have developed a very very little application in clojure that use an external lib in java that i prefer do not touch. The problem is that this lib for some weird reason (debug i guess) print at video a bunch of information useless for me, there is any way to avoid this problem, i mean can i just print what the clojure code actually print and not what also the lib in java print ? I'm sorry for my English... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
Mark Rathwell mark.rathw...@gmail.com writes: It's logging, and assuming the logging implementation it is using log4j, Why do you know that from the information given? Just in case the java lib in fact uses System.out/err directly, one can redirect standard out and error to something else. (with-open [w (clojure.java.io/writer /dev/null)] (binding [*out* w, *err* w] (.noisyJavaCall1 1 2 3) (.noisyJavaCall2 3 2 1))) Of course, /dev/null is somewhat platform specific. Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
Tassilo: I don't know it , but it is the most likely probability. One would hope that if a library is dumping to the console, or anywhere, it is done through a standard logging lib configurable by the client. If it turned out not to be the case, it would be evident quickly, and then try other possibilities. Sent from my iPhone On Feb 8, 2012, at 3:15 PM, Tassilo Horn tass...@member.fsf.org wrote: Mark Rathwell mark.rathw...@gmail.com writes: It's logging, and assuming the logging implementation it is using log4j, Why do you know that from the information given? Just in case the java lib in fact uses System.out/err directly, one can redirect standard out and error to something else. (with-open [w (clojure.java.io/writer /dev/null)] (binding [*out* w, *err* w] (.noisyJavaCall1 1 2 3) (.noisyJavaCall2 3 2 1))) Of course, /dev/null is somewhat platform specific. Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
On Wed, Feb 8, 2012 at 3:15 PM, Tassilo Horn tass...@member.fsf.org wrote: Mark Rathwell mark.rathw...@gmail.com writes: It's logging, and assuming the logging implementation it is using log4j, Why do you know that from the information given? Just in case the java lib in fact uses System.out/err directly, one can redirect standard out and error to something else. (with-open [w (clojure.java.io/writer /dev/null)] (binding [*out* w, *err* w] (.noisyJavaCall1 1 2 3) (.noisyJavaCall2 3 2 1))) Of course, /dev/null is somewhat platform specific. Will that work? I was under the impession that binding *out* and *err* had no effect on System/out or System/err. The OP may wish to use System/setOut and/or System/setErr instead of binding. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Print only by clojure code
Cedric Greevey cgree...@gmail.com writes: Hi Cedric, Just in case the java lib in fact uses System.out/err directly, one can redirect standard out and error to something else. (with-open [w (clojure.java.io/writer /dev/null)] (binding [*out* w, *err* w] (.noisyJavaCall1 1 2 3) (.noisyJavaCall2 3 2 1))) Of course, /dev/null is somewhat platform specific. Will that work? I was under the impession that binding *out* and *err* had no effect on System/out or System/err. No, it won't work. I tested it briefly in a slime repl and forgot the fact that java sysouts aren't printed in there anyway. So using your setOut/Err() advice, here's a java quitening macro that actually works: --8---cut here---start-8--- (defmacro without-java-output [ body] `(with-open [w# (java.io.PrintStream. /dev/null)] (let [oo# System/out, oe# System/err] (System/setOut w#) (System/setErr w#) (try ~@body (finally (System/setOut oo#) (System/setErr oe#)) (without-java-output (.println System/out Hello out) (.println System/err Hello err)) --8---cut here---end---8--- Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en