Thanks for your feedback guys!

It's interesting to see what your opinion is on the subject. I will be
posting my thoughts and some tests soon so we can keep discussing about
it.  :-)


--
David Martinez - Technical Animator

Email: [email protected]
Website: http://www.elusiveideas.com




On Mon, Jun 23, 2014 at 10:07 PM, Marcus Ottosson <[email protected]>
wrote:

> To be honest, I’m still bewildered by the global-ness of the logging
> module, but if it sounds like using it plainly isn’t fulfilling your needs
> and that you might be better of writing a small library to help you with it.
>
> # For example, globally forcing all logging to go offimport mylogging
> mylogging.force_global('off')
>
> There is one thing I did a while back that has stuck with me though, and
> that is an “append logging decorator”
>
> @mylogging.logclass MyTool(object):
>     ...
>
> Which mimics what I usually to for classes and logging, which is to use
> the full module path plus class name as logging root, making logging
> statements come out like:
>
> 22:02:25 - INFO - pifou.pom.path.WindowsPath - Could not replace basename
>
> So that I’d know from where the error came. Traditionally, I’d do
> something like:
>
> class WindowsPath(object):
>     log = logging.getLogger('pifou.pom.path.WindowsPath')
>
> And aside from the needless typing and duplicated information, moving the
> class elsewhere would invalidate the logging information. This would be
> something the decorator could handle instead.
>
> Possibly not helpful in your scenario, but I can’t offer much else on
> email notifications and such as I’ve never had to deal with it.
>
> Best,
> Marcus
> ​
>
>
> On 18 June 2014 14:07, Justin Israel <[email protected]> wrote:
>
>> For libraries that get imported by other things, you would just create an
>> instance of your named logger and use it.
>>
>> For the entry-point scripts (the ones that execute) you can create a
>> logger library that sets up all your common stuff, to that you can easily
>> import it and run it to set up your logger in a consistent way.
>>
>> Maybe you might not want to throw all logs for every app, at any time,
>> into a single log file. That might become unwieldy. A thought might be to
>> have your custom log setup split the logs by pid and possibly user, and
>> also rotate them by days, keeping up to N number? That way when a crash
>> happens, you will get a more relevant log file that represents the current
>> application session. Or if it is a Maya session they have kept open for a
>> week, you can at least be sure it will only be a days worth.
>> Ideally your email would send a full traceback of the crash. Logs can be
>> useful for when someone says "hey this thing isn't working", and you can
>> travel back through their process. But if you do have a sys.excepthook that
>> catches all unhandled exceptions, then you can log that exception
>> traceback, and the last 200 lines may be the useful ones.
>>
>>
>>
>>
>> On Wed, Jun 18, 2014 at 4:00 AM, David Martinez <
>> [email protected]> wrote:
>>
>>> Thanks Marcus!
>>>
>>> I look forward to reading the responses as well.   :-)
>>>
>>>
>>> --
>>> David Martinez - Technical Animator
>>>
>>> Email: [email protected]
>>> Website: http://www.elusiveideas.com
>>>
>>>
>>>
>>>
>>> On Wed, Jun 18, 2014 at 9:58 AM, Marcus Ottosson <[email protected]
>>> > wrote:
>>>
>>>> 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
>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAD_W899aTUV6rPy6O_oC17gqSEarXccyKyVhnoB4s6aQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>>> 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/CAMLeNpyooq7jVCcVkAi3m07v%2BiuoHcG5b0r4id4%2BYZK7TOw8dw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpyooq7jVCcVkAi3m07v%2BiuoHcG5b0r4id4%2BYZK7TOw8dw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> 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/CAPGFgA1PopiZkJqWFgwFWhBSW_rdfZRLqOxWr0iQYJExf70VSw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1PopiZkJqWFgwFWhBSW_rdfZRLqOxWr0iQYJExf70VSw%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/CAFRtmOD9N8ty-2GmE_rfXoGA5qDaVbRBa%3DaMZRedeSOs-ZAwxA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD9N8ty-2GmE_rfXoGA5qDaVbRBa%3DaMZRedeSOs-ZAwxA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMLeNpwxEb%3DY0zbwefBj7nt5pYyDMv_uLf61mVtE9eZVuUtqTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to