开发者

Java JNA redirecting output to logger

开发者 https://www.devze.com 2023-02-20 04:31 出处:网络
I am accessing OpenCV via JNA, when my processes takes too long the process a frame opencv prints a \"Camera dropped frame\" message. My problem is it produces too many messages which makes the consol

I am accessing OpenCV via JNA, when my processes takes too long the process a frame opencv prints a "Camera dropped frame" message. My problem is it produces too many messages which makes the console useless for my logging purposes. Below google code search shows it is printed to cout,

http://www.google.com/codesearch?hl=en&lr=&q=%22开发者_开发知识库camera+dropped+frame%21%22&sbtn=Search

I have tried to redirect both out and err to my logs but I still get the messages printed to console is there a way to get rid of them


      (System/setOut (proxy [java.io.PrintStream] [System/out] 
                       (print [s] ;;(trace s)
                              )
                       (println [s] ;;(trace s)
                                )
                       ))

      (System/setErr (proxy [java.io.PrintStream] [System/err] 
                       (print [s] ;;(trace s)
                              )
                       (println [s] ;;(trace s)
                                )
                       ))


Given you are using JNA to talk to OpenCV which probably implies to me that OpenCV is some native thing and probably not even aware of java. The next question is given it has no java API, why would it try and print messages using System.out ? Its probably calling the OS in the same way the default System.out does to print text to the console.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号