Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Log Generator

    Scheduled Pinned Locked Moved PYTHON Development
    7 Posts 0 Posters 574 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

      Hi 
      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

      Thanks

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

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

        -Niklas

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          http://docs.python.org/2/library/platform.html

          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.

          http://docs.python.org/2/tutorial/errors.html

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            thanks

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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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 ?

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                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.

                Best,
                -Niklas

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  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
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post