feature: add sortedarray semaphore

This commit is contained in:
2025-10-17 21:41:23 +08:00
parent a3479865c8
commit 4e71fbffc3
6 changed files with 521 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
import { CCLog, MINUTE, HOUR, SECOND } from "@/lib/ccLog";
import { CCLog, MINUTE, HOUR } from "@/lib/ccLog";
// Test the new time-based rotation functionality
function testTimeBasedRotation() {
@@ -9,25 +9,16 @@ function testTimeBasedRotation() {
logger1.info("This is a test message with default interval (1 day)");
// Test with custom interval (1 hour)
const logger2 = new CCLog("test_log_hourly.txt", HOUR);
const logger2 = new CCLog("test_log_hourly.txt", { logInterval: HOUR });
logger2.info("This is a test message with 1-hour interval");
// Test with custom interval (30 minutes)
const logger3 = new CCLog("test_log_30min.txt", 30 * MINUTE);
const logger3 = new CCLog("test_log_30min.txt", { logInterval: 30 * MINUTE });
logger3.info("This is a test message with 30-minute interval");
// Test with custom interval (5 seconds)
const logger4 = new CCLog("test_log_5sec.txt", 5 * SECOND);
logger4.info("This is a test message with 5-second interval");
for (let i = 0; i < 10; i++) {
logger4.info(`This is a test message with 5-second interval ${i}`);
sleep(1);
}
logger1.close();
logger2.close();
logger3.close();
logger4.close();
print("Test completed successfully!");
}