Skip to content

Commit

Permalink
Add DEFAULT_PRIORITY constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjboy committed Jun 5, 2018
1 parent 1e74853 commit 7673e03
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/alipay/sofa/common/log/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ public interface Constants {
//默认的中间件日志打印路径
String LOGGING_PATH_DEFAULT = System.getProperty("user.home")
+ File.separator + "logs";
// 默认优先级为0,越大越高
int DEFAULT_PRIORITY = 0;

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected URL getResource(ClassLoader spaceClassloader, List<URL> urls) throws I
} else {
List<ConfigFile> configFiles = new ArrayList<ConfigFile>();
for (URL url : urls) {
int priority = 0;
int priority = DEFAULT_PRIORITY;

File propertiesFile = new File(new File(url.getFile()).getParentFile(),
LOG_CONFIG_PROPERTIES);
Expand All @@ -133,7 +133,10 @@ protected URL getResource(ClassLoader spaceClassloader, List<URL> urls) throws I
inputStream = new FileInputStream(propertiesFile);
Properties properties = new Properties();
properties.load(inputStream);
priority = Integer.parseInt(properties.getProperty("priority", "0"));
String priorityStr = properties.getProperty("priority");
if (priorityStr != null) {
priority = Integer.parseInt(priorityStr);
}
} finally {
if (inputStream != null) {
inputStream.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@
import java.util.List;

/**
* @author xuanbei
* @since 2017/07/03
* @author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
*/
public class LoggerSpaceManagerOverrideUsageTest {
public class LoggerSpaceOverrideUsageTest {

@Test
public void testLog4j1() throws IOException {
public void testGetResource() throws IOException {
LoggerSpaceFactory4LogbackBuilder builder = new LoggerSpaceFactory4LogbackBuilder(
new SpaceInfo());
ClassLoader classLoader = LoggerSpaceManagerOverrideUsageTest.class.getClassLoader();
ClassLoader classLoader = LoggerSpaceOverrideUsageTest.class.getClassLoader();

Assert.assertNull(builder.getResource(classLoader, null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</layout>
</appender>


<root>
<level value="info"/>
<appender-ref ref="ROOT-APPENDER"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</layout>
</appender>


<root>
<level value="debug"/>
<appender-ref ref="ROOT-APPENDER"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</layout>
</appender>


<root>
<level value="debug"/>
<appender-ref ref="ROOT-APPENDER"/>
Expand Down

0 comments on commit 7673e03

Please sign in to comment.