Writing to Console on mac OS X

Irmen de Jong irmen.NOSPAM at xs4all.nl
Tue Mar 31 20:24:28 CEST 2009


RGK wrote:
> 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



More information about the Python-list mailing list