This small helper adds commands DebugStream.activate() and DebugStream.activate(...) with parameters. What this does is it modifies the functionality of the regular System.out.print* and System.err.print* and adds the time the code was executed and the line of code from where the message originated to the console when you print with the standard outs anything.
The second .activate(...) that has parameters starts logging the out to a file,
DebugErrStream.activate(fileID, maxFileAmount, maxSizeInMB, deleteLogsTime, path);
- fileID is a string, that is appended to the log file name, can be left empty and the time when activate is run will be used.
- maxFileAmount is the number of log files to keep
- maxSizeInMB is the mazimum size of each log file
- deleteLogsTime is the time in days how long the log files will be kept, a new thread will be started that will delete any files that it deems to be generated by this program
- path is a String representation for the directory where to store the log files, default is "/temp/debugstreamlog/"
Please note that this should not be used in place of regular logging. For that you should use an actual logging library such as log4j.
This is just a helpful tool that I use for my personal projects so I dont have to start a logger for small personal things.
Examples follow.
Example from Intellij IDEA, the reason for the lines being in incorrect order I blieve is the result of the standard out and standard error out printsteams not being synchronized in java
Example from Netbeans, do note that in my testing, mixing standard out and standard error out in netbeans with this tool
seems to mix up the console printing, so I recommend you only use the standard out version (DebugOutStream.activate();)