humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
getLogsByCallerFromSQLite
getLogsByCallerFromSQLite($callerName,$exactly=false,$startDateStr='',$endDateStr='',$offset=0,$pageSize=100); - Get log entries by caller with paginationФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Test: getLogsByCallerFromSQLite 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_getlogsbycaller.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: getLogsByCallerFromSQLite method:\n"; $testData = (object) ['test_key' => 'test_value']; SYSTEM::$logger->info("Caller test message 1", $testData, 'caller_1'); SYSTEM::$logger->info("Caller test message 2", $testData, 'caller_2'); SYSTEM::$logger->info("Caller test message 3", $testData, 'caller_3'); SYSTEM::$logger->info("Caller test message 4", $testData, 'caller_1'); SYSTEM::$logger->info("Caller test message 5", $testData, 'caller_2'); SYSTEM::$logger->info("Caller test message 6", $testData, 'caller_1'); sleep(1); $caller1Logs = SYSTEM::$logger->getLogsByCallerFromSQLite("caller_1", false, "", "", 0, 10); $caller1LogsCount = ($caller1Logs !== null) ? count($caller1Logs) : 0; echo "Тест #1. caller_1 logs: $caller1LogsCount (expected: 3) " . ($caller1LogsCount >= 3 ? "✓" : "✗") . "\n"; $caller2Logs = SYSTEM::$logger->getLogsByCallerFromSQLite("caller_2", false, "", "", 0, 10); $caller2LogsCount = ($caller2Logs !== null) ? count($caller2Logs) : 0; echo "Тест #2. caller_2 logs: $caller2LogsCount (expected: 2) " . ($caller2LogsCount >= 2 ? "✓" : "✗") . "\n"; $caller3Logs = SYSTEM::$logger->getLogsByCallerFromSQLite("caller_3", false, "", "", 0, 10); $caller3LogsCount = ($caller3Logs !== null) ? count($caller3Logs) : 0; echo "Тест #3. caller_3 logs: $caller3LogsCount (expected: 1) " . ($caller3LogsCount >= 1 ? "✓" : "✗") . "\n"; $nonExistentCallerLogs = SYSTEM::$logger->getLogsByCallerFromSQLite("nonexistent_caller", false, "", "", 0, 10); $nonExistentCallerLogsCount = ($nonExistentCallerLogs !== null) ? count($nonExistentCallerLogs) : 0; echo "Тест #4. nonexistent_caller logs: $nonExistentCallerLogsCount (expected: 0) " . ($nonExistentCallerLogsCount === 0 ? "✓" : "✗") . "\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.getLogsByCallerFromSQLite</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. Searching logs by caller 'TestFunction' (partial match): ") logs = logger.getLogsByCallerFromSQLite("TestFunction", exactly=False) if logs: echo("вњ“ Success: found entries - " + str(len(logs)) + "\n\n") else: echo("вњ— Failed\n\n") # 2 echo("2. Searching logs with exact caller match 'ManualTest': ") logs = logger.getLogsByCallerFromSQLite("ManualTest", exactly=True) if logs: echo("вњ“ Success: found entries - " + str(len(logs)) + "\n\n") else: echo("вњ— Failed\n\n") # 3 echo("3. Searching logs by caller with pagination: ") logs = logger.getLogsByCallerFromSQLite("Function", exactly=False, offset=0, pageSize=10) if logs: echo("вњ“ Success: found 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.getLogsByCallerFromSQLite</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 from specific caller 'TestCaller': "); object logs1 = logger.getLogsByCallerFromSQLite("TestCaller"); if(logs1 != null) echo("вњ“ Retrieved logs from TestCaller<br>"); else echo("вњ— No logs found from TestCaller<br>"); // 2 step echo("\n2. Get logs with partial caller name match (search 'Test'): "); object logs2 = logger.getLogsByCallerFromSQLite("Test", false); if(logs2 != null) echo("вњ“ Found logs from callers containing 'Test'<br>"); else echo("вњ— No logs found with partial caller name<br>"); // 3 step echo("\n3. Get logs from caller with date range: "); string today = DateTime.Now.ToString("dd.MM.yyyy"); object logs3 = logger.getLogsByCallerFromSQLite("DataManager", false, today, today); if(logs3 != null) echo("вњ“ Retrieved logs from DataManager for today<br>"); else echo("вњ— No logs found from DataManager with date range<br>"); // 4 step echo("\n4. Get logs from caller with pagination (pageSize=10): "); object logs4 = logger.getLogsByCallerFromSQLite("NetworkHandler", false, "", "", 0, 10); if(logs4 != null) echo("вњ“ Retrieved logs from NetworkHandler with pagination<br>"); else echo("вњ— No logs found from NetworkHandler<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() { var 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\"}", "TestCaller"); logger.addLogToSQLite(3, "Message 2", "{\"test\":\"data2\"}", "TestCaller"); logger.addLogToSQLite(2, "Message 3", "{\"test\":\"data3\"}", "AnotherCaller"); var logs = logger.getLogsByCallerFromSQLite("TestCaller", false, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 2) console.log("вњ“ Test 1: Get logs by caller 'TestCaller' - PASSED"); else console.log("вњ— Test 1: Get logs by caller 'TestCaller' - FAILED"); logs = logger.getLogsByCallerFromSQLite("AnotherCaller", false, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 1) console.log("вњ“ Test 2: Get logs by caller 'AnotherCaller' - PASSED"); else console.log("вњ— Test 2: Get logs by caller 'AnotherCaller' - FAILED"); logger.addLogToSQLite(2, "Message 4", "{\"test\":\"data4\"}", "TestCaller"); logs = logger.getLogsByCallerFromSQLite("TestCaller", true, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 3) console.log("вњ“ Test 3: Get logs by caller with exact match - PASSED"); else console.log("вњ— Test 3: Get logs by caller with exact match - FAILED"); logs = logger.getLogsByCallerFromSQLite("NonExistentCaller", false, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length === 0) console.log("вњ“ Test 4: Get logs by nonexistent caller - PASSED"); else console.log("вњ— Test 4: Get logs by nonexistent caller - FAILED"); } main();
=============================================
logger Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.