humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | Changelog

trace

trace($message,$data=null,$caller='',$isBold=false); - Log the Trace message

Функция на вход принимает параметры:

  • $message – Log message
  • $data – Data object or array
  • $caller – Caller name
  • $isBold – Highlight the messages in bold in the Log Panel?

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • результат – void

    Пример использования
    # 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.trace</font><hr>")
    
    # 1
    echo("1. Logging simple trace message: ")
    logger.trace("Test trace message")
    echo("✓ Success<br><br>")
    
    # 2
    echo("2. Logging trace message with data: ")
    logger.trace("Test trace with data", {"key": "value", "number": 123})
    echo("✓ Success<br><br>")
    
    # 3
    echo("3. Logging trace message with caller and isBold=True: ")
    logger.trace("Test trace with caller", caller="TestFunction", isBold=True)
    echo("✓ Success<br><br>")
    
    # end
    echo("<hr><br>")
    
    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.trace</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. Log simple trace message: ");
    		try {
    			logger.trace("This is a trace message");
    			echo("вњ“ Simple trace logged<br>");
    		} catch {
    			echo("вњ— Trace logging failed<br>");
    		}
    
    		// 2 step
    		echo("\n2. Log trace message with data object: ");
    		try {
    			var data = new { id = 1, name = "Test", value = 123.45 };
    			logger.trace("Trace with data", data);
    			echo("вњ“ Trace with data logged<br>");
    		} catch {
    			echo("вњ— Trace with data failed<br>");
    		}
    
    		// 3 step
    		echo("\n3. Log trace message with caller name: ");
    		try {
    			logger.trace("Trace from caller", null, "TestMethod");
    			echo("вњ“ Trace with caller logged<br>");
    		} catch {
    			echo("вњ— Trace with caller failed<br>");
    		}
    
    		// 4 step
    		echo("\n4. Log bold trace message: ");
    		try {
    			logger.trace("Bold trace message", null, "", true);
    			echo("вњ“ Bold trace logged<br>");
    		} catch {
    			echo("вњ— Bold trace failed<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()
    {
    	logger.init(0, true, true, "", "", "d-m-Y H:i:s", "en", false, true);
    	
    	try
    	{
    		logger.trace("Test trace message 1");
    		console.log("вњ“ Test 1: Trace with basic message - PASSED");
    	}
    	catch (e)
    	{
    		console.log("вњ— Test 1: Trace with basic message - FAILED");
    	}
    	
    	try
    	{
    		const testData = {key1: "value1", key2: 123};
    		logger.trace("Test trace message 2", testData);
    		console.log("вњ“ Test 2: Trace with data object - PASSED");
    	}
    	catch (e)
    	{
    		console.log("вњ— Test 2: Trace with data object - FAILED");
    	}
    	
    	try
    	{
    		logger.trace("Test trace message 3", null, "TestCaller");
    		console.log("вњ“ Test 3: Trace with caller parameter - PASSED");
    	}
    	catch (e)
    	{
    		console.log("вњ— Test 3: Trace with caller parameter - FAILED");
    	}
    	
    	try
    	{
    		logger.trace("Test trace message 4", {test: "data"}, "TestCaller2", true);
    		console.log("вњ“ Test 4: Trace with bold parameter - PASSED");
    	}
    	catch (e)
    	{
    		console.log("вњ— Test 4: Trace with bold parameter - FAILED");
    	}
    }
    
    main();

    =============================================
    logger    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .