Writing to Console on mac OS X

R

RGK

I'm on mac os x 10.4.11 running python 2.5.2, and Django 1.0, but this
is a python question.

When doing django/mod_python stuff, I can write to the Apache error_log
file with

sys.stderr.write("SOMETHING I WANT TO KNOW")

which had me wondering if there's not a means for a misc. python program
to write to the Mac OS X console? That would be much nicer than having
to open up the error log and inspect stuff, as then I could see debug
info stream past on a console window.

(This is console, as in the "console" run from /Applications/Utilities,
not the bash "Terminal")

Any help or suggestions appreciated. Thx.

Ross.
 
I

Irmen de Jong

RGK said:
I'm on mac os x 10.4.11 running python 2.5.2, and Django 1.0, but this
is a python question.

When doing django/mod_python stuff, I can write to the Apache error_log
file with

sys.stderr.write("SOMETHING I WANT TO KNOW")

which had me wondering if there's not a means for a misc. python program
to write to the Mac OS X console? That would be much nicer than having
to open up the error log and inspect stuff, as then I could see debug
info stream past on a console window.

(This is console, as in the "console" run from /Applications/Utilities,
not the bash "Terminal")

Any help or suggestions appreciated. Thx.

Ross.

Yeah, use the syslog facility, for instance:

import syslog
syslog.openlog("django")
syslog.syslog(syslog.LOG_ALERT, "Here is my syslog alert message")


It seems that anything below alert level isn't shown in the console.
I don't how to change this.


You might want to consider using the Python logging module instead?

--irmen
 
R

RGK

Thanks for the pointer Irmen. That works fine.

Also my unfamiliarity with the console app is showing - I just learned
that there is a navigation pane activated by the 'logs' icon that allows
me to see various system logs, including the Apache ones :p

You're right, I've heard a bit about the Python logging module, but
never looked into it. This is a good reason to take a look.

Thanks again & Regards,
Ross.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top