How to suppress output to stderr in a clojure program -


i want produce command line version of clojure library using clojure/tools.cli , lein bin. works fine except getting output stderr when run script. particular library has functions override basic functions, naturally there warnings when clojure code compiled. know bad idea after careful consideration in case believe best way go. how stop these messages appearing every time run script?

i added slf4j-nop dependencies recommended in monger documentation suppress unwanted messages monger, , works, has no effect on warnings clojure compiler.

i have tried using slf4j-log detailed here: suppress output `clojure.tools.logging` without success.

here of code:

project.clj

(defproject image-search "0.1.0-snapshot"   :description "search images containing specific metadata"   :url "http://github.com/soulflyer/image-search"   :license {:name "eclipse public license"         :url "http://www.eclipse.org/legal/epl-v10.html"}   :dependencies [[org.clojure/clojure "1.7.0"]                  [org.clojure/tools.cli "0.3.3"]                  [org.slf4j/slf4j-nop "1.7.21"]                  [image-lib "0.1.1-snapshot"]]   :main image-search.command-line   :bin {:name "image-search"         :bin-path "~/bin"}) 

and command_line.clj:

(ns image-search.command-line   (:require [image-search.core :refer [open all-images ifeq ifin ]]             [clojure.tools.cli  :refer :all])   (:gen-class))  (def cli-options   [["-c" "--count" "counts results"]    ["-d" "--database database" "specifies database use"     :default "photos"]    ["-i" "--image-collection image-collection" "specifies image collection"     :default "images"]    ["-k" "--keyword-collection keyword-collection" "specifies keyword collection"     :default "keywords"]    ["-h" "--help"]    ["-i" "--iso iso" "search on iso value"]    ["-s" "--shutter shutter-speed" "search on shutter-speed"]    ["-f" "--aperture aperture" "search on aperture"]    ["-y" "--year year" "search on year"]    ["-m" "--month month" "search on month"]    ["-m" "--model model" "search camera model"]    ["-p" "--project project" "search photos in project"]    ["-k" "--keyword keyword" "search keyword"]])  (defn print-count [pics]   (println (count pics)))  (defn -main   "i don't whole lot ... yet."   [& args]   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)         output-function (if (:count options) print-count open)]      (-> all-images         (ifeq :iso-speed-ratings   (:iso options))         (ifeq :year               (:year options))         (ifeq :month             (:month options))         (ifin :project         (:project options))         (ifeq :f-number       (:aperture options))         (ifin :keywords        (:keyword options))         (ifin :model             (:model options))         (output-function)))) 

i run lein bin, run executable produces , this:

(master) image-search: image-search -i 640 -c warning: or refers to: #'clojure.core/or in namespace: image-search.core, being replaced by: #'image-search.core/or warning: , refers to: #'clojure.core/and in namespace: image-search.core, being replaced by: #'image-search.core/and 

note 2 warning referring functions don't use in command line version. not including them. not in list given refer when :require library. are, however, important library when i'm using repl or cider. don't want rename them.

you can remove warning adding following (ns image-search.core) declaration:

(ns image-search.core   (:refer-clojure :exclude [or and]) 

with change can still use original clojure's or , and qualifying them:

`clojure.core/or` `clojure.core/and` 

without change compiler warns you overriding namespace binding of or , and default bound functions clojure.core/or , clojure/and vars.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -