forked from alibaba/Sentinel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change eagleEye log path when log base configured.
- Loading branch information
1 parent
4610bd3
commit 8554022
Showing
5 changed files
with
69 additions
and
27 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
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
36 changes: 36 additions & 0 deletions
36
sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/logger/EagleEyeLogUtilTest.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,36 @@ | ||
package com.alibaba.csp.sentinel.slots.logger; | ||
|
||
import java.io.File; | ||
|
||
import com.alibaba.csp.sentinel.log.LogBase; | ||
import com.alibaba.csp.sentinel.log.RecordLog; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author Carpenter Lee | ||
*/ | ||
public class EagleEyeLogUtilTest { | ||
|
||
@Test | ||
public void testWriteLog() throws Exception { | ||
EagleEyeLogUtil.log("resourceName", "BlockException", "app1", "origin", 1); | ||
Thread.sleep(1100); | ||
String file = RecordLog.getLogBaseDir() + EagleEyeLogUtil.FILE_NAME; | ||
assertTrue(new File(file).exists()); | ||
} | ||
|
||
@Test | ||
public void testChangeLogBase() throws Exception { | ||
String userHome = System.getProperty("user.home"); | ||
String newLogBase = userHome + File.separator + "tmpLogDir" + System.currentTimeMillis(); | ||
System.setProperty(LogBase.LOG_DIR, newLogBase); | ||
|
||
EagleEyeLogUtil.log("resourceName", "BlockException", "app1", "origin", 1); | ||
Thread.sleep(1100); | ||
String file = RecordLog.getLogBaseDir() + EagleEyeLogUtil.FILE_NAME; | ||
assertTrue(new File(file).exists()); | ||
} | ||
} |