Writing to Console on mac OS X

Discussion in 'Python' started by RGK, Mar 31, 2009.

  1. RGK

    RGK Guest

    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.
    RGK, Mar 31, 2009
    #1
    1. Advertising

  2. 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
    Irmen de Jong, Mar 31, 2009
    #2
    1. Advertising

  3. RGK

    RGK Guest

    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.

    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
    RGK, Mar 31, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    986
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    475
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    640
    Serge Terekhoff
    Jun 30, 2003
  4. Miktor
    Replies:
    7
    Views:
    12,031
    Joe Bacigalupa
    Aug 9, 2005
  5. Replies:
    5
    Views:
    3,425
    James Kanze
    Mar 4, 2008
Loading...

Share This Page