Skip to content

Commit 00f0e01

Browse files
committed
reformat 代码,保持阿里编码规范
1 parent 23a992a commit 00f0e01

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
/*
22
* Copyright 1999-2018 Alibaba Group Holding Ltd.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
76
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
98
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
1512
*/
1613
package com.alibaba.csp.sentinel.log;
1714

@@ -28,33 +25,33 @@
2825
*/
2926
class CspFormatter extends Formatter {
3027

31-
private final ThreadLocal<SimpleDateFormat> dateFormatThreadLocal = new ThreadLocal<SimpleDateFormat>() {
32-
@Override
33-
public SimpleDateFormat initialValue() {
34-
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
35-
}
36-
};
28+
private final ThreadLocal<SimpleDateFormat> dateFormatThreadLocal = new ThreadLocal<SimpleDateFormat>() {
29+
@Override
30+
public SimpleDateFormat initialValue() {
31+
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
32+
}
33+
};
3734

38-
@Override
39-
public String format(LogRecord record) {
40-
final DateFormat df = dateFormatThreadLocal.get();
41-
StringBuilder builder = new StringBuilder(1000);
42-
builder.append(df.format(new Date(record.getMillis()))).append(" ");
43-
builder.append(formatMessage(record));
35+
@Override
36+
public String format(LogRecord record) {
37+
final DateFormat df = dateFormatThreadLocal.get();
38+
StringBuilder builder = new StringBuilder(1000);
39+
builder.append(df.format(new Date(record.getMillis()))).append(" ");
40+
builder.append(formatMessage(record));
4441

45-
String throwable = "";
46-
if (record.getThrown() != null) {
47-
StringWriter sw = new StringWriter();
48-
PrintWriter pw = new PrintWriter(sw);
49-
pw.println();
50-
record.getThrown().printStackTrace(pw);
51-
pw.close();
52-
throwable = sw.toString();
53-
}
54-
builder.append(throwable);
55-
if ("".equals(throwable)) {
56-
builder.append("\n");
57-
}
58-
return builder.toString();
59-
}
42+
String throwable = "";
43+
if (record.getThrown() != null) {
44+
StringWriter sw = new StringWriter();
45+
PrintWriter pw = new PrintWriter(sw);
46+
pw.println();
47+
record.getThrown().printStackTrace(pw);
48+
pw.close();
49+
throwable = sw.toString();
50+
}
51+
builder.append(throwable);
52+
if ("".equals(throwable)) {
53+
builder.append("\n");
54+
}
55+
return builder.toString();
56+
}
6057
}

0 commit comments

Comments
 (0)