Is there a way to see the errors of python code or anything that pis printed in asterisk cli

I am running python code in asterisk AGI. At multiple cases the AGI don’t run when developing. Is there any way to see where the code breaks by inserting print or by simply catching the error and showing in asterisk console.

Can i use flask to see the python console to see error. If so I need a hello world example and dial plan since i could find any

You can use ! to escape to a local shell and then use Unix commands to access the filesystem, e.g for any logs produced by python, for a log file explicitly written by your scrip (possibly standard error, or the Asterisk logs to see the result of enabling AGI debugging.

If you enable AGI debugging ('agi set debug on'), the dialog between Asterisk and your AGI will be displayed on the console.

Using an established AGI library will reduce your debugging effort.

If you are logging (for example, debug or verbose messages) within your AGI you should be using syslog(). Private log files are evil.

at this level of development in your dialplan, I would suggest you halt everything you are doing and give the lua extension a couple days of study, you will be amazed what can be achieved using pbx_lua. just my 2 cents.

You’ve piqued my interest :slight_smile:

Tell me more…

What can I do in lua that I can’t in classic dialplan or AEL?

Omg. You will get your sanity back, string manipulation, loops, database access, and most important thing, as long as your call is up your script can control it and can see everything , no need for troubleshooting hangup handlers, well, its like taking a programmer living in the 90s and bringing him to 2021:D

I mean honestly, I always wonder why the Asterisk code developers don’t move on from the regular dialplan of asterisk, its so old, so impractical, unless of course you just want to receive a call and ring an extension (a need of the 90s) but not anymore, today a call IS ALAWAYS connected to external applications, otherwise no one will call us for a telephony solution, they would just buy some closed source box and use it, yes of course there is ARI but yet you have all the responsibility on your back to manage the call from start to finish, which task the core developers have already done perfectly, IMHO, we just need to boost work on pbx_lua, maybe bring python into the equation, lua is beautifully designed, you send your call to a function and the function stays alive untill you want to hangup the call, its just perfectly handles all the needs of a developer, we just need to manager a call from start to finish in a human way, opensips, kamailio have already integrated python, imagine all the python libraries at your finger tips and full access to a call, I mean its a world changer.
Lets hope we see that happen to Asterisk.