mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-07 23:32:42 +01:00
Date:2011-01-11T22:14:55.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@731 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
89 lines
2.8 KiB
Plaintext
89 lines
2.8 KiB
Plaintext
[[Property:title|Tracing]]
|
|
[[Property:weight|8]]
|
|
[[Property:uuid|ecb9dd1e-52a9-25c4-b27b-4b5ec806b115]]
|
|
{{UnderConstruction}}
|
|
|
|
|
|
{{ReviewRequested}}
|
|
|
|
|
|
=Introduction=
|
|
|
|
The '''tracing facility''' allows you to see a structured log of the flow of control through your system, feature by feature. By default, execution traces are written to standard output.
|
|
|
|
=The "Trace" project setting=
|
|
|
|
You can make tracing usable for a particular cluster by setting the '''Trace''' setting to '''True''' in your project settings for a particular cluster.
|
|
|
|
To do this:
|
|
* Open the [[Group Options|Project Settings]] dialog.
|
|
* Under '''Clusters''' select the cluster you want to see traced.
|
|
* Set the value of '''Trace''' to '''True'''.
|
|
* Click '''Apply''' or '''OK'''.
|
|
* You must [[Generating executables|recompile]] your project for the changes to take effect.
|
|
|
|
This will cause a trace entry to be written to the console for any feature execution on a class in the cluster(s) you selected for tracing. To get a feel for this, look at the following trace outputs, built on the default Eiffel application ("Hello Eiffel World!).
|
|
|
|
First, here's what the "Hello Eiffel World!" output looks like without using the tracing facility.
|
|
|
|
|
|
[[Image:Tracing 01 off]]
|
|
|
|
|
|
Next, here's the output when the '''Trace''' project setting is set to '''True''' on the root cluster.
|
|
|
|
|
|
[[Image:Tracing 01 on]]
|
|
|
|
|
|
Last, here's the output when '''Trace''' is '''True''' for both the root cluster and EiffelBase.
|
|
|
|
|
|
[[Image:Tracing 01 with EiffelBase]]
|
|
|
|
|
|
=Dynamic control=
|
|
|
|
It is also possible to enable and disable the trace dynamically. To do this:
|
|
* Create an object of type [[ref:/libraries/base/reference/tracing_setting_chart|TRACING_SETTING]] .
|
|
* Call [[ref:libraries/base/reference/tracing_setting_flatshort|enable_tracing]] on this object to start the trace.
|
|
* Call [[ref:libraries/base/reference/tracing_setting_flatshort|disable_tracing]] on this object to stop the trace.
|
|
|
|
{{tip|To enable tracing on only part of a system, disable tracing at the very beginning of the program, enable it just before the part of the code that should be traced, and then disable it again after this section. The code below illustrates this tip. }}
|
|
|
|
|
|
In the root feature:
|
|
|
|
<code>
|
|
local
|
|
ts: TRACING_SETTING
|
|
-- Other local variables if necessary.
|
|
do
|
|
create ts.make
|
|
ps.disable_tracing
|
|
-- Program execution continues.
|
|
...
|
|
end
|
|
</code>
|
|
|
|
|
|
Then, in a feature in which tracing is desired:
|
|
|
|
<code>
|
|
local
|
|
ts: TRACING_SETTING
|
|
-- Other local variables if necessary.
|
|
do
|
|
create ts.make
|
|
ps.enable_tracing -- Enable trace
|
|
-- Section needing trace.
|
|
...
|
|
ps.disable_tracing -- Disable trace
|
|
end
|
|
</code>
|
|
|
|
|
|
|
|
|
|
|