LeVanPhuUIT / jnativehook

Automatically exported from code.google.com/p/jnativehook
0 stars 0 forks source link

Unwanted INFO messages #98

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Set up a nativeMouseMotionListener (I'm not interested in keyboard events for 
this particular project, so I haven't set up any native keyboard listeners), 
and when I press keys I see huge amounts of output that I don't want (see 
below).  Is there a DEBUG feature that was accidentally left on in this release?

What is the expected output? What do you see instead?
No output.

What version of the product are you using? On what operating system?
2.02.

Please provide any additional information below.

Jul 13, 2015 10:44:50 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: keycode_to_unicode [651]: Using keyboard layout 0X0000000004091009.

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_key_pressed [220]: Key 0X1D pressed. (0XA2)

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: keycode_to_unicode [651]: Using keyboard layout 0X0000000004091009.

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_key_pressed [220]: Key 0X1D pressed. (0XA2)

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: keycode_to_unicode [651]: Using keyboard layout 0X0000000004091009.

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_key_pressed [220]: Key 0X1D pressed. (0XA2)

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: keycode_to_unicode [651]: Using keyboard layout 0X0000000004091009.

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_key_pressed [220]: Key 0X2E pressed. (0X43)

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: keycode_to_unicode [651]: Using keyboard layout 0X0000000004091009.

Jul 13, 2015 10:44:51 PM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_key_pressed [245]: Key 0 typed. (c)

Original issue reported on code.google.com by randolf....@gmail.com on 14 Jul 2015 at 6:11

GoogleCodeExporter commented 8 years ago
Hi,

There are instructions in the wiki on GitHub to disable logging.  Please file 
future bug reports on GitHub as google code is going away.

https://github.com/kwhat/jnativehook/wiki/Usage#logging-and-console-output

Original comment by a...@1stleg.com on 14 Jul 2015 at 8:05

GoogleCodeExporter commented 8 years ago
Thank you, the following code (included hereunder) helped for stopping most of 
the output, but there still is some output initially (some of the LGPL text).  
All the output should really be disabled by default, optionally with options to 
enable as needed (or separate sets of "debug" and "production" classes could be 
made available) -- going through the java.util.logging.Logger class to shut off 
what should be off by default is extra code that doesn't completely solve the 
problem.

The console output is important because it is redirected as part of automation, 
and so I need to have complete control over it.  For my projects, I always 
include third party license information in accompanying README files, and also 
in the GUI (usually under the "Help" menu) when a GUI is part of the project.  
I also include hypertext links to the web sites for said third party projects, 
and make them linkable where possible.  Having the license appear every time my 
code is run is disruptive, particularly if my code is supposed to output just 
one or two lines that report on something (which is generally quite easy for a 
Unix script to assign to a variable when only one line of output is generated).

At any rate, your solution is helpful, and mostly solves my problem, and I do 
appreciate the time you've taken to reply to me -- thank you.

(P.S.:  I don't have a GitHub account, and so I appreciate you responding to me 
here; one day I may get one, but I do find the GitHub system confusing so I'll 
need some time to "get up to speed" on it, but there's another problem -- the 
last time I tried to get an account there the "+" symbol in my eMail address 
was rejected so I just gave up.)

-----
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.jnativehook.GlobalScreen;

Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
for (Handler handler: Logger.getLogger("").getHandlers())
  handler.setLevel(Level.OFF);

Original comment by randolf....@gmail.com on 15 Jul 2015 at 4:25

GoogleCodeExporter commented 8 years ago
I will take your feedback into consideration for the next release.  I had left 
the GPL licence information in the output because the library has a high 
likely-hook for abuse by people who do not include licence information in their 
projects. I'm still trying to gauge how effective it is vs how many people are 
legitimately frustrated with the output. As far as logging being enabled by 
default, that is more of a Java default log level thing.  The only thing I 
could do is change the log level of the info events, but I don't feel like 
that's a good solution.  Individuals depending on console output should 
configure the logger for their application as this and other libraries may log 
warnings or errors in addition to info events.  In the mean time, you can 
recompile the project to disable console output.  I spent a lot of time on the 
build scripts for this project to make it as easy as possible to compile from 
source.  There are instructions in the 
[wiki](https://github.com/kwhat/jnativehook/wiki/Compiling) for setting up and 
compiling on various platforms. You will need to run `ant configure` and then 
edit `build.properties` to add `-DUSE_QUIET=1` to the cflags property.  That 
will disable the licence info and all of the logging.  All of the 
[cross-compiler](https://github.com/kwhat/crossdev-apple-overlay) packages are 
also provided on my [github account](https://github.com/kwhat/) if you need to 
build for multiple platforms.  If you have trouble compiling, feel free to send 
me an email or drop by #jnativehook on irc.freenode.net.

Original comment by a...@1stleg.com on 15 Jul 2015 at 2:34

GoogleCodeExporter commented 8 years ago
Thank you.  I will look into the compilation scripts then because that looks 
like it will solve the problem for me.

Unfortunately there are people who will purposely ignore licenses, and probably 
Adobe has been the biggest victim of this with the unauthorized copies of 
Photoshop being popularly shared on the internet, so I understand your concern. 
 And with open source software it's even easier for people to misuse or ignore 
licenses because they don't have to go through any reverse engineering steps.  
The good news is that of all the people I know who are in professional software 
development positions do take the licenses seriously, and a few of them have 
had to expend time and effort to educate upper management about open source 
licenses (and have been successful at making sure licenses were being respected 
properly).

I appreciate your offer for help on irc.freenode.net#jnativehook -- the IRC 
network has been a useful resource that I've also contributed to helping others 
on in certain open source projects (including NetBSD, OpenVPN, Xen, etc.), but 
I do value your time so I'll be careful to use these resources sparingly.

Original comment by randolf....@gmail.com on 15 Jul 2015 at 3:24