Hi SG team,
is possible to disable or skip printing from shotgun in Maya and any other Software?
example of SG printing…
// Debug: Shotgun storage_roots:
// Shotgun tank_init:
// Debug: Shotgun tank_init:
etc…
Hi SG team,
is possible to disable or skip printing from shotgun in Maya and any other Software?
example of SG printing…
// Debug: Shotgun storage_roots:
// Shotgun tank_init:
// Debug: Shotgun tank_init:
etc…
Hi Lukas
Thanks for the question!
There are a few things to say here:
root_logger
:import sgtk
import logging
lm = sgtk.LogManager()
lm.root_logger.setLevel(logging.ERROR)
This will affect the logging to the logs as well as the software’s console.Best
Phil
Hi Phil,
I think that would be good if I could disable it only for this part of code?
pth = mc.file (q=True, sn=True)
tk = sgtk.sgtk_from_path(pth)
ctx = tk.context_from_path(pth)
shotCode = ctx.entity['name']
# get project ID
projId = ctx.project['id']
for key,values in listDictNodes.iteritems():
#print key, 'key'
#print path.split('/')[-1]
if '/assets/' in values['ref_path']:
template_obj = tk.templates["maya_asset_publish"]
fields = template_obj.get_fields(values['ref_path'])
specific_filter = ['entity.Asset.code','is',fields['Asset']]
else:
template_obj = tk.templates["maya_shot_publish"]
fields = template_obj.get_fields(values['ref_path'])
specific_filter = ['entity.Shot.code','is',fields['Shot']]
get_fields = ['code','version_number','path']
filters = [
['project', 'is', {'type': 'Project', 'id': int(projId)}],
specific_filter,
#['task.Task.content','is',fields_step],
['task.Task.step.Step.code','is',fields['Step']]
]
order = [{'field_name':'id','direction':'desc'}]
pubFiles = shotgun.find_one("PublishedFile", filters, get_fields, order = order)
also this does not work:
lm = sgtk.LogManager()
lm.root_logger.setLevel(logging.ERROR)
# Error: NameError: file <maya console> line 2: name 'logging' is not defined #
Ah, you’re quite right, I missed out the import of logging
. I’ve updated my example above.
I’m as yet, unsure what the best approach would be to disable the logging from that section of code would be. As the code itself doesn’t have any direct logging, I presume you would like to stop any logging coming from the sgtk methods you are calling?
You could set the logging level at the top and then again at the bottom, but I think that would probably be bad practice. You would need to grab the current logging level at the top and then reinstate it at the end.
I think that could work. Thanks. Anyway it is good to know that there is a way how to disable debug print from SG.
We had a bit of a chat internally, and we think what I suggested is probably the right thing to do.
If you do end up doing it, I would probably put the code in a try/except
so that it restored the logging level in the event that the code failed.