humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
getLogsByPeriodFromSQLite
getLogsByPeriodFromSQLite($startDateStr,$endDateStr,$offset=0,$pageSize=100); - Get all log entries by period with paginationФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Test: getLogsByPeriodFromSQLite method $xhe_host = getenv("RPABOT_HOST_URL"); if (!isset($path)){ $path = "../../../Templates/init.php"; require($path); } echo "\n<span >logger->" . basename(__FILE__) . "</span>\n"; $dbPath = __DIR__ . "/logs/test_getlogsbyperiod.db"; echo "\n"; echo "Initializing logger with SQLite DB...\n"; echo "Initializing logger with parameters:\n"; $minLogLevel = LogLevel::DEBUG; echo "- Min Log Level: DEBUG (value: $minLogLevel)\n"; $phpUseThroughShell = true; echo "- PHP Use Through Shell: " . ($phpUseThroughShell ? "true" : "false") . "\n"; $writeLogToLogPanel = false; echo "- Write Log To Log Panel: " . ($writeLogToLogPanel ? "true" : "false") . "\n"; $logFilePath = ""; echo "- Log File Path: ''\n"; $logSQLiteDbFilePath = $dbPath; echo "- Log SQLite DB Path: '$logSQLiteDbFilePath'\n"; echo "- Date Time Format: d-M-yyyy HH:mm:ss (default)\n"; echo "- Localization Code: en (default)\n"; echo "- Need Text Transliteration: false (default)\n"; SYSTEM::$logger->init($minLogLevel, $phpUseThroughShell, $writeLogToLogPanel, $logFilePath, $logSQLiteDbFilePath); echo "Logger initialized with SQLite DB: $dbPath\n"; echo "\n\n"; echo "Test: getLogsByPeriodFromSQLite method:\n"; $testData = (object) ['test_key' => 'test_value']; SYSTEM::$logger->info("Today's log message 1", $testData, 'period_test'); SYSTEM::$logger->info("Today's log message 2", $testData, 'period_test'); sleep(1); $today = date('d/m/Y'); $yesterday = date('d/m/Y', strtotime('-1 day')); $logsByPeriod = SYSTEM::$logger->getLogsByPeriodFromSQLite($yesterday, $today, 0, 10); if ($logsByPeriod && count($logsByPeriod) > 0) { echo "Retrieved " . count($logsByPeriod) . " logs from period $yesterday to $today\n"; } else { echo "No logs retrieved for period\n"; } $logsToday = SYSTEM::$logger->getLogsByPeriodFromSQLite($today, $today, 0, 10); echo "Retrieved " . count($logsToday) . " logs from today ($today)\n"; echo "\n✓ Test completed successfully!\n"; echo "\n"; WINDOW::$app->quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7019" from xweb_human_emulator import * # start echo("<hr><font color=blue>logger.getLogsByPeriodFromSQLite</font><hr>") echo("Initializing logger using SQLite for log storage: ") if logger.init(logSQLiteDbFilePath=debug.get_cur_script_folder() + "/logs/logger.db"): echo("вњ“ Success\n\n") else: echo("вњ— Failed\n\n") # 1 echo("1. Getting logs for entire period (without dates): ") logs = logger.getLogsByPeriodFromSQLite("", "", offset=0, pageSize=10) if logs: echo("вњ“ Success: found entries - " + str(len(logs)) + "\n\n") else: echo("вњ— Failed\n\n") # 2 echo("2. Getting logs for period (start 01.01.2024, end 31.12.2025): ") logs = logger.getLogsByPeriodFromSQLite("01.01.2024", "31.12.2025", offset=0, pageSize=20) if logs: echo("вњ“ Success: found entries - " + str(len(logs)) + "\n\n") else: echo("вњ— Failed\n\n") # 3 echo("3. Getting logs for period with pagination: ") logs = logger.getLogsByPeriodFromSQLite("01.01.2024", "31.12.2025", offset=0, pageSize=5) if logs: echo("вњ“ Success: retrieved entries - " + str(len(logs)) + "\n\n") else: echo("вњ— Failed\n\n") # end echo("\n") app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { server = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); echo("<hr><font color=blue>logger.getLogsByPeriodFromSQLite</font><hr>"); echo("0. Initialize logger: "); bool initResult = logger.init(0, true, true, "", "test\\logger_test.db"); if(initResult) echo("вњ“ Init successful<br>"); else echo("вњ— Init failed<br>"); // 1 step echo("\n1. Get logs for today: "); string today = DateTime.Now.ToString("dd.MM.yyyy"); object logs1 = logger.getLogsByPeriodFromSQLite(today, today); if(logs1 != null) echo("вњ“ Retrieved logs for today<br>"); else echo("вњ— No logs found for today<br>"); // 2 step echo("\n2. Get logs for last week with pagination: "); string weekAgo = DateTime.Now.AddDays(-7).ToString("dd.MM.yyyy"); object logs2 = logger.getLogsByPeriodFromSQLite(weekAgo, today, 0, 50); if(logs2 != null) echo("вњ“ Retrieved logs for last week<br>"); else echo("вњ— No logs found for last week<br>"); // 3 step echo("\n3. Get logs for specific date range (last 3 days): "); string threeDaysAgo = DateTime.Now.AddDays(-3).ToString("dd.MM.yyyy"); object logs3 = logger.getLogsByPeriodFromSQLite(threeDaysAgo, today); if(logs3 != null) echo("вњ“ Retrieved logs for last 3 days<br>"); else echo("вњ— No logs found for last 3 days<br>"); // 4 step echo("\n4. Get logs with custom page size (pageSize=20): "); object logs4 = logger.getLogsByPeriodFromSQLite("", "", 0, 20); if(logs4 != null) echo("вњ“ Retrieved logs with page size 20<br>"); else echo("вњ— No logs found with custom page size<br>"); echo("\n\n"); app.quit(); } }
const xhe_host = "127.0.0.1:7019"; require("../../../Templates JS/init.js"); const path = require("path"); async function main() { const dbPath = path.join(__dirname, "/logs/test_logger.db"); logger.init(1, true, true, "", dbPath, "d-m-Y H:i:s", "en", false, true); logger.addLogToSQLite(2, "Message 1", "{\"test\":\"data1\"}", "Caller1"); logger.addLogToSQLite(2, "Message 2", "{\"test\":\"data2\"}", "Caller2"); logger.addLogToSQLite(3, "Message 3", "{\"test\":\"data3\"}", "Caller3"); let logs = logger.getLogsByPeriodFromSQLite("", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 3) console.log("вњ“ Test 1: Get all logs without period filter - PASSED"); else console.log("вњ— Test 1: Get all logs without period filter - FAILED"); logs = logger.getLogsByPeriodFromSQLite("01.01.2020", "31.12.2030", 0, 100); if (logs !== null && Array.isArray(logs)) console.log("вњ“ Test 2: Get logs by period - PASSED"); else console.log("вњ— Test 2: Get logs by period - FAILED"); logger.addLogToSQLite(2, "Message 4", "{\"test\":\"data4\"}", "Caller4"); logs = logger.getLogsByPeriodFromSQLite("", "", 0, 3); if (logs !== null && Array.isArray(logs) && logs.length <= 3) console.log("вњ“ Test 3: Get logs with page size limit - PASSED"); else console.log("вњ— Test 3: Get logs with page size limit - FAILED"); logs = logger.getLogsByPeriodFromSQLite("", "", 1, 2); if (logs !== null && Array.isArray(logs)) console.log("вњ“ Test 4: Get logs with offset - PASSED"); else console.log("вњ— Test 4: Get logs with offset - FAILED"); } main();
=============================================
logger Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.