Debugger¶
The core
Debugger
component is the standard way to debug your
circuits applications. It services two purposes:
Logging events as they flow through the system.
Logging any exceptions that might occurs in your application.
Usage¶
Using the Debugger
in your application is
very straight forward just like any other component
in the circuits component library. Simply add it
to your application and register it somewhere
(it doesn’t matter where).
Example:
1from circuits import Component, Debugger
2
3
4class App(Component):
5 """Your Application"""
6
7
8app = App()
9Debugger().register(app)
10app.run()
Sample Output(s)¶
Here are some example outputs that you should
expect to see when using the Debugger
component in your application.
Example Code:
1from circuits import Event, Component, Debugger
2
3
4class foo(Event):
5 """foo Event"""
6
7
8class App(Component):
9
10 def foo(self, x, y):
11 return x + y
12
13
14app = App() + Debugger()
15app.start()
Run with:
python -i app.py
Logged Events:
<registered[*] (<Debugger/* 27098:App (queued=0) [S]>, <App/* 27098:App (queued=2) [R]> )>
<started[*] (<App/* 27098:App (queued=1) [R]> )>
>>> app.fire(foo(1, 2))
<Value () result=False; errors=False; for <foo[*] (1, 2 )>
>>> <foo[*] (1, 2 )>
Logged Exceptions:
>>> app.fire(foo())
<Value () result=False; errors=False; for <foo[*] ( )>
>>> <foo[*] ( )>
<exception[*] (<type 'exceptions.TypeError'>, TypeError('foo() takes exactly 3 arguments (1 given)',), [' File "/home/prologic/work/circuits/circuits/core/manager.py", line 561, in _dispatcher\n value = handler(*eargs, **ekwargs)\n'] handler=<bound method App.foo of <App/* 27098:App (queued=1) [R]>>, fevent=<foo[*] ( )>)>
ERROR <handler[*][foo] (App.foo)> (<foo[*] ( )>) {<type 'exceptions.TypeError'>}: foo() takes exactly 3 arguments (1 given)
File "/home/prologic/work/circuits/circuits/core/manager.py", line 561, in _dispatcher
value = handler(*eargs, **ekwargs)