473,412 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

tracing function calls

Greetings,

I've been wondering if there is a mechanism similar to trace/untrace
found in lisp, for example call trace(function-name) and whenever this
function is called it will show its parameters to stdout ....

Jul 19 '05 #1
2 1774
"Stormbringer" wrote:
I've been wondering if there is a mechanism similar to trace/untrace
found in lisp, for example call trace(function-name) and whenever this
function is called it will show its parameters to stdout ....


def trace(func):
def tracer(*args, **kwargs):
print func.__name__, args, kwargs
result = func(*args, **kwargs)
print func.__name__, "return", result
return result
return tracer

def myfunc(a, b, c):
return a + b + c

myfunc = trace(myfunc)

myfunc(1, 2, 3)

(tweak as necessary)

</F>

Jul 19 '05 #2
Thank you Fredrik !
With a little tweaking for the right indentation it should prove useful
:)

Fredrik Lundh wrote:
"Stormbringer" wrote:
I've been wondering if there is a mechanism similar to trace/untrace found in lisp, for example call trace(function-name) and whenever this function is called it will show its parameters to stdout ....


def trace(func):
def tracer(*args, **kwargs):
print func.__name__, args, kwargs
result = func(*args, **kwargs)
print func.__name__, "return", result
return result
return tracer

def myfunc(a, b, c):
return a + b + c

myfunc = trace(myfunc)

myfunc(1, 2, 3)

(tweak as necessary)

</F>


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DigitalDragon | last post by:
hi, i would like to trace the function that called the "current" function. i need a type char name of that function. is that posibile? eg. void function() { char string;
5
by: Stig | last post by:
I would like to output the sequence of method calls from a running c# applcaition, but I don't want to add Debug.trace calls at the entry and exit points in each an every methods. Does there...
0
by: Paul Ibison | last post by:
HI when I have a page which calls a component I want to do the following - tracing set to false on the pag tracing set to true in the componen tracing set to false in the page after the call to...
6
by: serge calderara | last post by:
Dear all, I have an applicatin that generate a querry to an SQL server, then display results on a second webform. I try to see how tracing works, then I have notice that as soon as I...
2
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page....
4
by: Corno | last post by:
Hi all, My collegue finds tracing very important and therefore we have agreed that we will do quite a lot of it. The first and last line of every function will contain a trace stating which...
0
by: cnys | last post by:
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it. The tracing functionality within .NET is great, but when we output this to a file, it's kind of sparse. So, we're looking...
4
by: magennisw | last post by:
Our three tier web application is "pausing" under test loading (IIS 6.0 (win2003) -> Web services (win2003) -> SQL server) . The CPU usage on the W3WP.exe on both the web server and middle tier...
6
by: Stephen Torri | last post by:
I am trying to produce a singleton class that I can use throughout my library to write tracing information to a file. My intent was to design such that someone using the library in its debug mode...
2
by: jimocz | last post by:
Hi, I have a set of libraries that I have built. I also have a main program recently built. I need to deliver source code for the main. I want to deliver the minimal set of library functions. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.