处理信息 @param message 日志信息 @param args 占位符替换 @return 处理 ( 格式化 ) 后准备打印的日志信息
(
final String message,
final Object... args
)
| 107 | * @return 处理 ( 格式化 ) 后准备打印的日志信息 |
| 108 | */ |
| 109 | private static String createMessage( |
| 110 | final String message, |
| 111 | final Object... args |
| 112 | ) { |
| 113 | String result; |
| 114 | try { |
| 115 | if (message != null) { |
| 116 | if (args == null) { |
| 117 | // 动态参数为 null |
| 118 | result = "params is null"; |
| 119 | } else { |
| 120 | // 格式化字符串 |
| 121 | result = (args.length == 0 ? message : String.format(message, args)); |
| 122 | } |
| 123 | } else { |
| 124 | // 打印内容为 null |
| 125 | result = "message is null"; |
| 126 | } |
| 127 | } catch (Exception e) { |
| 128 | // 出现异常 |
| 129 | result = e.toString(); |
| 130 | } |
| 131 | return result; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * 拼接错误信息 |