Log Generator

  • On 18/08/2013 at 16:39, xxxxxxxx wrote:

    I Look for an Way to Log Errors and save them

    Also is there a Way to Generate a System Description with Details of the Computer and Version of c4d

    I like to get a Way to get Most detailed error Reports


  • On 18/08/2013 at 22:09, xxxxxxxx wrote:

    Take a look at the logging module, it is part of the Python STL.


  • On 19/08/2013 at 01:30, xxxxxxxx wrote:

    In the c4d module you can find various methods to retrieve OS and c4d related informations, you 
    can also retrieve your gpu specs from the WPREF container. The python stl module platform can 
    be used to retrieve OS and CPU related informations. Some of these informations can also be 
    found in the environment dict.


    I am not sure what is meant with errors in this context. I guess you are speaking of runtime 
    errors / exceptions. There is no method to automatically redirect exceptions in Python (at least 
    I do not know one), so you will have to stick with the try/except syntax to track them. From the
    except branches in your code you could feed then a logger class to generate a log string. You
    could also build an generic exception class wrapping other exceptions, which would pass the
    the exception string to your logger.


  • On 21/08/2013 at 15:18, xxxxxxxx wrote:


    with errors i mean the errors messages with come up in the console

  • On 28/12/2013 at 11:47, xxxxxxxx wrote:

    to bring it up again -

    the logging work great

    is there a way to get the content of the console ?

  • On 29/12/2013 at 07:42, xxxxxxxx wrote:

    You could overwrite sys.stdout with your own file-like object that redirects the write() calls to the original
    stdout and your own file. You should prefer to use your own printing mechanism however to not break
    other plugins or scripts in case your implementation is buggy.

    > import logging
    > import cStringIO as cstio
    > logfile = cstio.StringIO()
    > logger = logging.Logger("conner's logger")
    > logger.addHandler(logging.StreamHandler(logfile))
    > logger.addHandler(logging.StreamHandler(sys.stdout))
    > def get_log(self) :
    >     logfile.seek(0)
    >     data = logfile.read()
    >     logfile.seek(0, 2)
    >     return data

    Simply put everything into the logger instead of using the print keyword.


  • On 29/12/2013 at 07:55, xxxxxxxx wrote:

    hey Niklas,

    thanks for your detailed answer. 
    your logging example is great. my problem is i don`t get the errors like this

    Traceback (most recent call last) :
      File "'stage.pyp'", line 1848, in all
    AttributeError: parameter access failed

Log in to reply