Great initiatives, David. I'll try and chime in a bit later today. Looking
forward to what others will come up with, both in this and your other
thread on JSON.


On 18 June 2014 09:54, David Martinez <[email protected]> wrote:

> Hello again,
>
> I want to revisit all my scripts and make sure that I'm using Python's
> logging module instead of 'print' statements. I want to take advantage of
> the different logging levels and the possibility to save logs to a file.
>
> I'm not sure if this is the best way of doing it but what I've been doing
> so far is to create the logger using the following lines of code in all my
> scripts:
>
>     logger = logging.getLogger(__name__)
>     logger.setLevel(logging.DEBUG)
>     handler = logging.FileHandler(r'g:\nameOfTheTool.log')
>     formatter = logging.Formatter('%(asctime)s ::: %(filename)s :::
> %(funcName)s() ::: %(message)s')
>     handler.setFormatter(formatter)
>     logger.addHandler(handler)
>
> Even though that this does the trick, it does not quite achieve what I
> have in mind. Here are the things that I want:
>
>
>    - All information should be logged to the same file (regardless of the
>    tool/module/package executing it).
>    - Being able to spit different levels on file and on Maya
>    - Being able to specify the level in two ways:
>
>    - Globally (Forcing all levels to be the one I specify)
>       - On a Tool/Module/Package basis
>
>
> Not sure if this makes sense...
>
> In addition to that, I'm wondering if I should be using a rolling log
> file. I want to set it up in a way that if any of the scripts fails, an
> email will be automatically created and the log will be attached so I can
> get the information that I need. It also means that I don't have to wait
> until things get flagged up. Instead, I will get notified.
>
> It would be great to know how you guys are using the logging module and
> getting notified when things don't work the way we expected.
>
>
> Thanks in advance
>
>
> --
> David Martinez - Technical Animator
>
> Email: [email protected]
> Website: http://www.elusiveideas.com
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpwXAFETERZyb1cBqew-tv4AJhnPQmhMQAOu7WR02w_7Yg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpwXAFETERZyb1cBqew-tv4AJhnPQmhMQAOu7WR02w_7Yg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAD_W899aTUV6rPy6O_oC17gqSEarXccyKyVhnoB4s6aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to