|
6 | 6 |
|
7 | 7 | public class ResultPrinter { |
8 | 8 |
|
| 9 | + private static String formatReturn(String methodName, long costedMillis, String returnVal) { |
| 10 | + String threadName = Thread.currentThread().getName(); |
| 11 | + if (!"main".equals(threadName)) { |
| 12 | + return "⇠ [" + threadName + "] " + methodName + "[" + costedMillis + "ms]=\"" + returnVal + "\""; |
| 13 | + } |
| 14 | + return String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMillis + "", returnVal); |
| 15 | + } |
| 16 | + |
9 | 17 | public static void print(String className, String methodName, long costedMilles, byte returnVal) { |
10 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 18 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
11 | 19 | } |
12 | 20 |
|
13 | 21 | public static void print(String className, String methodName, long costedMilles, char returnVal) { |
14 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 22 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
15 | 23 | } |
16 | 24 |
|
17 | 25 | public static void print(String className, String methodName, long costedMilles, short returnVal) { |
18 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 26 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
19 | 27 | } |
20 | 28 |
|
21 | 29 | public static void print(String className, String methodName, long costedMilles, int returnVal) { |
22 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 30 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
23 | 31 | } |
24 | 32 |
|
25 | 33 | public static void print(String className, String methodName, long costedMilles, boolean returnVal) { |
26 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 34 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
27 | 35 | } |
28 | 36 |
|
29 | 37 | public static void print(String className, String methodName, long costedMilles, long returnVal) { |
30 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 38 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
31 | 39 | } |
32 | 40 |
|
33 | 41 | public static void print(String className, String methodName, long costedMilles, float returnVal) { |
34 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 42 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
35 | 43 | } |
36 | 44 |
|
37 | 45 | public static void print(String className, String methodName, long costedMilles, double returnVal) { |
38 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 46 | + Log.i(className, formatReturn(methodName, costedMilles, returnVal + "")); |
39 | 47 | } |
40 | 48 |
|
41 | 49 | public static void print(String className, String methodName, long costedMilles, Object returnVal) { |
42 | 50 | if(returnVal != null && returnVal.getClass().isArray()){ |
43 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", arrayToString(returnVal))); |
| 51 | + Log.i(className, formatReturn(methodName, costedMilles, arrayToString(returnVal))); |
44 | 52 | } else { |
45 | | - Log.i(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal)); |
| 53 | + Log.i(className, formatReturn(methodName, costedMilles, String.valueOf(returnVal))); |
46 | 54 | } |
47 | 55 | } |
48 | 56 |
|
49 | 57 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, byte returnVal) { |
50 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 58 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
51 | 59 | } |
52 | 60 |
|
53 | 61 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, char returnVal) { |
54 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 62 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
55 | 63 | } |
56 | 64 |
|
57 | 65 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, short returnVal) { |
58 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 66 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
59 | 67 | } |
60 | 68 |
|
61 | 69 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, int returnVal) { |
62 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 70 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
63 | 71 | } |
64 | 72 |
|
65 | 73 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, boolean returnVal) { |
66 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 74 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
67 | 75 | } |
68 | 76 |
|
69 | 77 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, long returnVal) { |
70 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 78 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
71 | 79 | } |
72 | 80 |
|
73 | 81 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, float returnVal) { |
74 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 82 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
75 | 83 | } |
76 | 84 |
|
77 | 85 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, double returnVal) { |
78 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal + "")); |
| 86 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, returnVal + "")); |
79 | 87 | } |
80 | 88 |
|
81 | 89 | public static void printWithCustomLogger(String className, String methodName, long costedMilles, Object returnVal) { |
82 | 90 | if(returnVal != null && returnVal.getClass().isArray()){ |
83 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", arrayToString(returnVal))); |
| 91 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, arrayToString(returnVal))); |
84 | 92 | } else { |
85 | | - HunterLoggerHandler.CUSTOM_IMPL.log(className, String.format(Constants.RETURN_PRINT_FORMAT, methodName, costedMilles + "", returnVal)); |
| 93 | + HunterLoggerHandler.CUSTOM_IMPL.log(className, formatReturn(methodName, costedMilles, String.valueOf(returnVal))); |
86 | 94 | } |
87 | 95 | } |
88 | 96 |
|
|
0 commit comments