Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Writing to Console on mac OS X

Reply
Thread Tools

Writing to Console on mac OS X

 
 
RGK
Guest
Posts: n/a
 
      03-31-2009
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.
 
Reply With Quote
 
 
 
 
Irmen de Jong
Guest
Posts: n/a
 
      03-31-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
 
Reply With Quote
 
 
 
 
RGK
Guest
Posts: n/a
 
      03-31-2009

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

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.

Irmen de Jong wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading console output and writing to console jan.rebada@gmail.com C++ 5 03-04-2008 09:00 AM
Preventing the console window from closing when writing a console program in C++ Miktor C++ 7 08-09-2005 09:22 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Serge Terekhoff Python 0 06-30-2003 12:36 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Egor Bolonev Python 0 06-30-2003 10:43 AM
Re: console mp3->wav decoder for $indows or GUI one which supports console Ben Finney Python 2 06-30-2003 05:43 AM



Advertisments