humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
exportLogsByPeriodFromSQLiteToTextFile
exportLogsByPeriodFromSQLiteToTextFile($filePath,$startDateStr='',$endDateStr=''); - Export log entries for period from SQLite database to text or HTML fileФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
# 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.exportLogsByPeriodFromSQLiteToTextFile</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. Exporting logs for entire period to TXT file: ") txtPath = debug.get_cur_script_folder() + "/logs/logs.txt" if logger.exportLogsByPeriodFromSQLiteToTextFile(txtPath, "", ""): echo("вњ“ Success: file created\n\n") else: echo("вњ— Failed\n\n") # 2 echo("2. Exporting logs for period to HTML file: ") htmlPath = debug.get_cur_script_folder() + "/logs/logs.html" if logger.exportLogsByPeriodFromSQLiteToTextFile(htmlPath, "01.01.2024", "31.12.2025"): echo("вњ“ Success: file created\n\n") else: echo("вњ— Failed\n\n") # 3 echo("3. Exporting logs for short period to TXT file: ") txtPath = debug.get_cur_script_folder() + "/logs/logs_period.txt" if logger.exportLogsByPeriodFromSQLiteToTextFile(txtPath, "01.01.2024", "01.01.2024"): echo("вњ“ Success: file created\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.exportLogsByPeriodFromSQLiteToTextFile</font><hr>"); echo("0. Initialize logger and add test data: "); bool initResult = logger.init(0, true, true, "", "test\\logger_test.db"); if(initResult) echo("вњ“ Init successful<br>"); else echo("вњ— Init failed<br>"); echo("0.1. Add test logs: "); logger.addLogToSQLite(0, "Text export test 1", "{\"data\":\"test1\"}", "TextExportTest"); logger.addLogToSQLite(2, "Text export test 2", "{\"data\":\"test2\"}", "TextExportTest"); logger.addLogToSQLite(4, "Text export test 3", "{\"data\":\"test3\"}", "TextExportTest"); echo("вњ“ Test logs added<br>"); // 1 step echo("\n1. Export logs to plain text file: "); bool result1 = logger.exportLogsByPeriodFromSQLiteToTextFile("test\\logs_export.txt"); if(result1) echo("вњ“ Exported to text file<br>"); else echo("вњ— Failed to export to text file<br>"); // 2 step echo("\n2. Export logs to HTML file: "); bool result2 = logger.exportLogsByPeriodFromSQLiteToTextFile("test\\logs_export.html"); if(result2) echo("вњ“ Exported to HTML file<br>"); else echo("вњ— Failed to export to HTML file<br>"); // 3 step echo("\n3. Export logs for specific date period (today): "); string today = DateTime.Now.ToString("dd.MM.yyyy"); bool result3 = logger.exportLogsByPeriodFromSQLiteToTextFile("test\\logs_today.txt", today, today); if(result3) echo("вњ“ Exported today's logs to text file<br>"); else echo("вњ— Failed to export logs for today<br>"); // 4 step echo("\n4. Export logs to file and verify creation: "); string exportPath = "test\\custom_logs_export.txt"; bool result4 = logger.exportLogsByPeriodFromSQLiteToTextFile(exportPath); if(result4 && File.Exists(exportPath)) { long fileSize = new FileInfo(exportPath).Length; if(fileSize > 0) echo("вњ“ File created and verified (size: " + fileSize + " bytes)<br>"); else echo("вњ— File exists but is empty<br>"); } else echo("вњ— Failed to create export file<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_export_period.db"); logger.init(1, true, true, "", dbPath, "d-m-Y H:i:s", "en", false, true); logger.addLogToSQLite(2, "Export period message 1", "{\"test\":\"data1\"}", "Caller1"); logger.addLogToSQLite(2, "Export period message 2", "{\"test\":\"data2\"}", "Caller2"); logger.addLogToSQLite(3, "Export period message 3", "{\"test\":\"data3\"}", "Caller3"); let txtPath = path.join(__dirname, "/test/export_period.txt"); let result = logger.exportLogsByPeriodFromSQLiteToTextFile(txtPath, "", ""); if (result === true) console.log("вњ“ Test 1: Export all logs to text file - PASSED"); else console.log("вњ— Test 1: Export all logs to text file - FAILED"); txtPath = path.join(__dirname, "/test/export_period_filter.txt"); result = logger.exportLogsByPeriodFromSQLiteToTextFile(txtPath, "01.01.2020", "31.12.2030"); if (result === true) console.log("вњ“ Test 2: Export logs by period to text file - PASSED"); else console.log("вњ— Test 2: Export logs by period to text file - FAILED"); var htmlPath = path.join(__dirname, "/test/export_period.html"); result = logger.exportLogsByPeriodFromSQLiteToTextFile(htmlPath, "", ""); if (result === true) console.log("вњ“ Test 3: Export all logs to HTML file - PASSED"); else console.log("вњ— Test 3: Export all logs to HTML file - FAILED"); logger.addLogToSQLite(1, "Debug export period", "{\"debug\":\"data\"}", "Caller4"); htmlPath = path.join(__dirname, "/test/export_period_filter.html"); result = logger.exportLogsByPeriodFromSQLiteToTextFile(htmlPath, "01.01.2020", "31.12.2030"); if (result === true) console.log("вњ“ Test 4: Export logs by period to HTML file - PASSED"); else console.log("вњ— Test 4: Export logs by period to HTML file - FAILED"); } main();
=============================================
logger Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.