Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Online Java - IDE, Code Editor, Compiler
- Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
- */
- import java.util.Date;
- import java.lang.StackTraceElement;
- public class Main
- {
- public static void main(String[] args) {
- Logger.debug("Welcome to Online IDE!! Happy Coding :)");
- new Thread(new Runnable(){
- public void run() {
- try {
- Thread.sleep(1000);
- } catch(Exception e) {
- }
- new BadAssLogic().badAssMethod();
- }
- }, "BadAssThread").start();
- new BadAssLogic().badAssMethod();
- }
- private static class BadAssLogic {
- public void badAssMethod() {
- Logger.debug("Let's do some bad ass!");
- }
- }
- private static class Logger {
- public static void debug(String message) {
- try {
- long threadid = Thread.currentThread().getId();
- String threadName = Thread.currentThread().getName();
- StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
- StringBuilder builder = new StringBuilder();
- builder.append("[" + new Date() + "] [" + threadid + "] [" + threadName + "] " + message).append("\n");
- for (int i = 2; i < stacktrace.length; i ++) {
- builder.append(stacktrace[i]).append("\n");
- }
- System.out.println(builder.toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement