Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Logging in Eclipse Titan part IV: Dynamic Configuration of Logging Options
Logging in Eclipse Titan part IV: Dynamic Configuration of Logging Options [message #1722337] Thu, 04 February 2016 08:05
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
As we have seen in part I , Logging in Eclipse Titan part I : Configuration
( https://www.eclipse.org/forums/index.php/t/1073933/ ),

by default the configuration of logging is static, that is, the configuration parameters are being read at the start of execution and remain valid throughout. However , Titan offers the possibility to change some of the parameters during execution. This is described in detail in Ch 7.13 of the reference guide.

The interface is contained in (TTCN3_DIR)/include/TitanLoggerControl.ttcn; this file needs to be added to the project. TitanLoggerControl.ttcn contains definitions of various external functions which can be called from TTCN-3 code. The implementation of these external functions is built into the Titan runtime library and it will be linked automatically.


The individual logging severities are contained in the "Severity" enumerated type.
A logging mask is represented by a "record of":
type record of Severity Severities;


For each logging bit set, the "record of" will contain an element.

The TitanLoggerControl module defines several constants:

const Severities log_nothing    := {};
const Severities log_console_default := { ... }
const Severities log_all := { ... } // LOG_ALL, without MATCHING,DEBUG
const Severities log_everything := { ... } // really everything


These constants can be used when setting logger options.
Each function has a parameter named plugin, to specify which plugin is being manipulated. Currently, the value of the plugin parameter must be "LegacyLogger".

The current values of the logger file mask/console masks can be retrieved with:

get_file_mask(in charstring plugin) return Severities;
get_console_mask(in charstring plugin) return Severities;


The following functions set the file mask or console mask, overwriting their previous value:

set_file_mask(in charstring plugin, in Severities s);
set_console_mask(in charstring plugin, in Severities s);


With

add_to_file_mask(in charstring plugin, in Severities s);
add_to_console_mask(in charstring plugin, in Severities s);

and

remove_from_file_mask(in charstring plugin, in Severities s);
remove_from_console_mask(in charstring plugin, in Severities s);


individual severites can be added removed to/from the masks.

The log file name can be also manipulated dynamically ( although I'm not sure why someone would like to do that, but hey, who am I to stop you).
Reading and writing of the LogEntityName parameter can be done as well on-the-fly:

set_log_entity_name(in charstring plugin, in boolean b);
get_log_entity_name(in charstring plugin) return boolean;



Let's try and execute the next code sequence:


module hello {

import from TitanLoggerControl all;

  type component CT {}
  testcase tc1() runs on CT {

var  Severities v_Severities:=get_file_mask("LegacyLogger");
log(v_Severities)
set_file_mask("LegacyLogger", log_everything);
    log("Hello Titan!");
    setverdict(pass,"Everything is ok");
set_file_mask("LegacyLogger", v_Severities)
  }
  
  testcase tc2() runs on CT {
var  Severities v_Severities:=get_file_mask("LegacyLogger");
log(v_Severities)

set_file_mask("LegacyLogger", log_nothing);
    log("Hello Titan!");
    setverdict(fail,"Something was wrong");
set_file_mask("LegacyLogger", v_Severities)


  }
control {
  execute(tc1());
  execute(tc2());
}

}


As you can see in the generated log, log results are influenced by changing the logging parameters on-the-fly:

13:27:06.328921 TTCN-3 Main Test Component started on esekilxxen1842. Version: CRL 113 200/5 R4C.
13:27:06.329126 TTCN Logger v2.2 options: TimeStampFormat:=Time; LogEntityName:=No; LogEventTypes:=No; SourceInfoFormat:=None; *.FileMask:=LOG_ALL; *.ConsoleMask:=ACTION | ERROR | TESTCASE | STATISTICS | WARNING; LogFileSize:=0; LogFileNumber:=1; DiskFullAction:=Error
13:27:06.329254 Connected to MC.
13:27:06.336906 Executing control part of module hello.
13:27:06.336996 Execution of control part in module hello started.
13:27:06.337082 Test case tc1 started.
13:27:06.337145 Initializing variables, timers and ports of component type hello.CT inside testcase tc1.
13:27:06.337208 Component type hello.CT was initialized.
13:27:06.337269 { ACTION_UNQUALIFIED (1), DEFAULTOP_ACTIVATE (2), DEFAULTOP_DEACTIVATE (3), DEFAULTOP_EXIT (4), DEFAULTOP_UNQUALIFIED (5), ERROR_UNQUALIFIED (6), EXECUTOR_RUNTIME (7), EXECUTOR_CONFIGDATA (8), EXECUTOR_EXTCOMMAND (9), EXECUTOR_COMPONENT (10), EXECUTOR_LOGOPTIONS (11), EXECUTOR_UNQUALIFIED (12), FUNCTION_RND (13), FUNCTION_UNQUALIFIED (14), PARALLEL_PTC (15), PARALLEL_PORTCONN (16), PARALLEL_PORTMAP (17), PARALLEL_UNQUALIFIED (18), TESTCASE_START (19), TESTCASE_FINISH (20), TESTCASE_UNQUALIFIED (21), PORTEVENT_PQUEUE (22), PORTEVENT_MQUEUE (23), PORTEVENT_STATE (24), PORTEVENT_PMIN (25), PORTEVENT_PMOUT (26), PORTEVENT_PCIN (27), PORTEVENT_PCOUT (28), PORTEVENT_MMRECV (29), PORTEVENT_MMSEND (30), PORTEVENT_MCRECV (31), PORTEVENT_MCSEND (32), PORTEVENT_DUALRECV (33), PORTEVENT_DUALSEND (34), PORTEVENT_UNQUALIFIED (35), STATISTICS_VERDICT (36), STATISTICS_UNQUALIFIED (37), TIMEROP_READ (38), TIMEROP_START (39), TIMEROP_GUARD (40), TIMEROP_STOP (41), TIMEROP_TIMEOUT (42), TIMEROP_UNQUALIFIED (43), USER_UNQUALIFIED (44), VERDICTOP_GETVERDICT (45), VERDICTOP_SETVERDICT (46), VERDICTOP_FINAL (47), VERDICTOP_UNQUALIFIED (48), WARNING_UNQUALIFIED (49) }
13:27:06.337471 Hello Titan!
13:27:06.337498 setverdict(pass): none -> pass reason: "Everything is ok", new component reason: "Everything is ok"
13:27:06.337557 Terminating component type hello.CT.
13:27:06.337588 Component type hello.CT was shut down inside testcase tc1.
13:27:06.337614 Waiting for PTCs to finish.
13:27:06.337730 Setting final verdict of the test case.
13:27:06.337781 Local verdict of MTC: pass reason: "Everything is ok"
13:27:06.337827 No PTCs were created.
13:27:06.337854 Test case tc1 finished. Verdict: pass reason: Everything is ok
13:27:06.337910 Test case tc2 started.
13:27:06.337950 Initializing variables, timers and ports of component type hello.CT inside testcase tc2.
13:27:06.337979 Component type hello.CT was initialized.
13:27:06.338019 { ACTION_UNQUALIFIED (1), DEFAULTOP_ACTIVATE (2), DEFAULTOP_DEACTIVATE (3), DEFAULTOP_EXIT (4), DEFAULTOP_UNQUALIFIED (5), ERROR_UNQUALIFIED (6), EXECUTOR_RUNTIME (7), EXECUTOR_CONFIGDATA (8), EXECUTOR_EXTCOMMAND (9), EXECUTOR_COMPONENT (10), EXECUTOR_LOGOPTIONS (11), EXECUTOR_UNQUALIFIED (12), FUNCTION_RND (13), FUNCTION_UNQUALIFIED (14), PARALLEL_PTC (15), PARALLEL_PORTCONN (16), PARALLEL_PORTMAP (17), PARALLEL_UNQUALIFIED (18), TESTCASE_START (19), TESTCASE_FINISH (20), TESTCASE_UNQUALIFIED (21), PORTEVENT_PQUEUE (22), PORTEVENT_MQUEUE (23), PORTEVENT_STATE (24), PORTEVENT_PMIN (25), PORTEVENT_PMOUT (26), PORTEVENT_PCIN (27), PORTEVENT_PCOUT (28), PORTEVENT_MMRECV (29), PORTEVENT_MMSEND (30), PORTEVENT_MCRECV (31), PORTEVENT_MCSEND (32), PORTEVENT_DUALRECV (33), PORTEVENT_DUALSEND (34), PORTEVENT_UNQUALIFIED (35), STATISTICS_VERDICT (36), STATISTICS_UNQUALIFIED (37), TIMEROP_READ (38), TIMEROP_START (39), TIMEROP_GUARD (40), TIMEROP_STOP (41), TIMEROP_TIMEOUT (42), TIMEROP_UNQUALIFIED (43), USER_UNQUALIFIED (44), VERDICTOP_GETVERDICT (45), VERDICTOP_SETVERDICT (46), VERDICTOP_FINAL (47), VERDICTOP_UNQUALIFIED (48), WARNING_UNQUALIFIED (49) }
13:27:06.338149 Terminating component type hello.CT.
13:27:06.338175 Component type hello.CT was shut down inside testcase tc2.
13:27:06.338200 Waiting for PTCs to finish.
13:27:06.338284 Setting final verdict of the test case.
13:27:06.338318 Local verdict of MTC: fail reason: "Something was wrong"
13:27:06.338353 No PTCs were created.
13:27:06.338379 Test case tc2 finished. Verdict: fail reason: Something was wrong
13:27:06.338422 Execution of control part in module hello finished.
13:27:06.344836 Verdict statistics: 0 none (0.00 %), 1 pass (50.00 %), 0 inconc (0.00 %), 1 fail (50.00 %), 0 error (0.00 %).
13:27:06.344961 Test execution summary: 2 test cases were executed. Overall verdict: fail
13:27:06.345003 Exit was requested from MC. Terminating MTC.



As logging is resource-intensive, this offers the possibility to switch on logging only in parts of code execution that are expected to offer relevant or critical information.





Best regards

Elemer

Previous Topic:Implicit Omit
Next Topic:Titan Eclipse plug-ins released in open source
Goto Forum:
  


Current Time: Fri Apr 26 15:23:56 GMT 2024

Powered by FUDForum. Page generated in 0.03274 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top