humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
getLogsByMessageFromSQLite
getLogsByMessageFromSQLite($messageText,$exactly=false,$logLevelCode=-1,$startDateStr='',$endDateStr='',$offset=0,$pageSize=100); - Get log entries by message text, level and period with paginationФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Test: getLogsByMessageFromSQLite with exact match $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_getlogsbymessage_exact.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: getLogsByMessageFromSQLite with exact match:\n"; $testData = (object) ['test_key' => 'test_value']; SYSTEM::$logger->info("Test message for SQLite DB", $testData, 'exact_test'); SYSTEM::$logger->info("Another test message for SQLite DB", $testData, 'exact_test'); SYSTEM::$logger->info("Different message", $testData, 'exact_test'); sleep(1); $exactMessage = "Test message for SQLite DB"; $logsExact = SYSTEM::$logger->getLogsByMessageFromSQLite($exactMessage, true, -1, "", "", 0, 10); if ($logsExact && count($logsExact) > 0) { echo "Retrieved " . count($logsExact) . " logs with exact message match: '$exactMessage'\n"; foreach ($logsExact as $log) { echo " - Message: $log->message\n"; } } else { echo "No logs with exact message match found\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.getLogsByMessageFromSQLite</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 containing text 'test' (partial match): ") logs = logger.getLogsByMessageFromSQLite("test", 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 message match: ") logs = logger.getLogsByMessageFromSQLite("Test info message", exactly=True) if logs: echo("вњ“ Success: found entries - " + str(len(logs)) + "\n\n") else: echo("вњ— Failed\n\n") # 3 echo("3. Searching error logs containing 'error' with pagination: ") logs = logger.getLogsByMessageFromSQLite("error", exactly=False, logLevelCode=4, offset=0, pageSize=5) 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.getLogsByMessageFromSQLite</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. Find logs containing specific text (search 'error'): "); object logs1 = logger.getLogsByMessageFromSQLite("error", false); if(logs1 != null) echo("вњ“ Found logs containing 'error'<br>"); else echo("вњ— Failed to find logs containing 'error'<br>"); // 2 step echo("\n2. Find logs with exact message match: "); object logs2 = logger.getLogsByMessageFromSQLite("Test log", true); if(logs2 != null) echo("вњ“ Found logs with exact message match<br>"); else echo("вњ— No logs found with exact message<br>"); // 3 step echo("\n3. Find logs by message with level filter (level=2, search 'info'): "); object logs3 = logger.getLogsByMessageFromSQLite("info", false, 2); if(logs3 != null) echo("вњ“ Found info logs containing 'info'<br>"); else echo("вњ— Failed to find info logs with message<br>"); // 4 step echo("\n4. Find logs by message with date range: "); string today = DateTime.Now.ToString("dd.MM.yyyy"); object logs4 = logger.getLogsByMessageFromSQLite("log", false, -1, today, today); if(logs4 != null) echo("вњ“ Found logs for today containing 'log'<br>"); else echo("вњ— Failed to find logs with date range<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, "Test message with keyword", "{\"test\":\"data1\"}", "Caller1"); logger.addLogToSQLite(2, "Another test message", "{\"test\":\"data2\"}", "Caller2"); logger.addLogToSQLite(3, "Warning message with keyword", "{\"warn\":\"data1\"}", "Caller3"); let logs = logger.getLogsByMessageFromSQLite("keyword", false, -1, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 2) console.log("вњ“ Test 1: Get logs containing 'keyword' - PASSED"); else console.log("вњ— Test 1: Get logs containing 'keyword' - FAILED"); logs = logger.getLogsByMessageFromSQLite("Test message", false, 2, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 2) console.log("вњ“ Test 2: Get logs containing 'Test message' with level filter - PASSED"); else console.log("вњ— Test 2: Get logs containing 'Test message' with level filter - FAILED"); logger.addLogToSQLite(2, "Exact match message", "{\"test\":\"data3\"}", "Caller4"); logs = logger.getLogsByMessageFromSQLite("Exact match message", true, 2, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length >= 1) console.log("вњ“ Test 3: Get logs with exact message match - PASSED"); else console.log("вњ— Test 3: Get logs with exact message match - FAILED"); logs = logger.getLogsByMessageFromSQLite("nonexistent", false, -1, "", "", 0, 100); if (logs !== null && Array.isArray(logs) && logs.length === 0) console.log("вњ“ Test 4: Get logs with nonexistent message - PASSED"); else console.log("вњ— Test 4: Get logs with nonexistent message - FAILED"); } main();
=============================================
logger Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.