I have a Log class that has several static methods which help log information about my program.
My problem is that I have 2 threads running and both of them send requests to my Log class to log information.
I would like to have my Log class show which threads are logging which lines.
What should I do to achieve this functionality?
My code is basically like this:
public class Log {
public static void log ( String tag , Object message )
{
String lineToPrint = "";
//Builds the string taking in time data and other information
//...
//This is where I want to see which thread called this log function
//...
System.out.println( lineToPrint );
}
}
Add this to your logger:
Thread t = Thread.currentThread();
String name = t.getName();
and dump it to log file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With