winIDEA SDK
test_logger.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6import isystem.connect as ic
7
8
9winidea_id = ''
10
11
12def test_logger():
13 connMgr = ic.ConnectionMgr()
14 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
15 print(f"Current logger ID: {connMgr.getId()}")
16
17 print("Initialize new logger...")
18 connMgr.initLogger("test_logger", "test_logger_out.py", ic.CLogger.PYTHON)
19 logger = connMgr.getLogger()
20
21 # a few examples of how logger can be used:
22 logger.setIndent(2)
23 logger.createVar("someInt", "int")
24 logger.log("someInt = 42")
25 logger.log("main()")
26 logger.logc("my visible comment")
27
28 logger.loggingOff()
29 logger.logc("will not be visible")
30 logger.loggingOn()
31
32 logger.closeLog("# end comment")
33
34 filePath = "test_logger_out.py"
35 print(f"Content of the created log file: {filePath}")
36 with open(filePath, "r") as fHandler:
37 print("'''")
38 print(fHandler.read())
39 print("'''")
40
41
42if __name__ == "__main__":
43 test_logger()