forked from apache/incubator-seata
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize: datasource manager branch rollback exception log (apache#1775)
- Loading branch information
Showing
8 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/src/main/java/io/seata/core/logger/StackTraceLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.core.logger; | ||
|
||
import io.seata.config.Configuration; | ||
import io.seata.config.ConfigurationFactory; | ||
import io.seata.core.constants.ConfigurationKeys; | ||
import org.slf4j.Logger; | ||
|
||
/** | ||
* @author jsbxyyx | ||
*/ | ||
public final class StackTraceLogger { | ||
|
||
private static final Configuration CONFIG = ConfigurationFactory.getInstance(); | ||
|
||
public static void info(Logger logger, Throwable cause, String format1, Object[] args1, String format2, Object[] args2) { | ||
if (logger.isInfoEnabled()) { | ||
int rate = CONFIG.getInt(ConfigurationKeys.TRANSACTION_LOG_EXCEPTION_RATE, 100); | ||
if (System.currentTimeMillis() % rate == 0) { | ||
logger.info(format1, args1, cause); | ||
} else { | ||
logger.info(format2, args2); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...arter/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/LogProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.file; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static io.seata.spring.boot.autoconfigure.StarterConstants.LOG_PREFIX; | ||
|
||
/** | ||
* @author jsbxyyx | ||
*/ | ||
@Component | ||
@ConfigurationProperties(prefix = LOG_PREFIX) | ||
public class LogProperties { | ||
|
||
private int exceptionRate = 100; | ||
|
||
public int getExceptionRate() { | ||
return exceptionRate; | ||
} | ||
|
||
public LogProperties setExceptionRate(int exceptionRate) { | ||
this.exceptionRate = exceptionRate; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters