Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions docs/cookbook/usage_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,38 @@ automatically set whenever an entity is created or updated.
Logging Messages from the API
*****************************

The API uses standard python logging but does not define a handler.
The library uses the standard Python logging module under the logger name
``shotgun_api3``. Developers are free to configure logging handlers as they see
fit in their applications.

To see the logging output in stdout, define a streamhandler in your script::

import logging
import shotgun_api3 as shotgun
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig()

import shotgun_api3

sg_log = logging.getLogger("shotgun_api3")
sg_log.setLevel(logging.DEBUG)


To write logging output from the Flow Production Tracking API to a file, define a file handler in your script::

import logging
import shotgun_api3 as shotgun
logging.basicConfig(level=logging.DEBUG, filename='/path/to/your/log')
logging.basicConfig(filename="/path/to/your/log")

import shotgun_api3

sg_log = logging.getLogger("shotgun_api3")
sg_log.setLevel(logging.DEBUG)


To suppress the logging output from the API in a script which uses logging, set the level of the
Flow Production Tracking logger to a higher level::

import logging
import shotgun_api3 as shotgun
sg_log = logging.getLogger('shotgun_api3')
sg_log = logging.getLogger("shotgun_api3")
sg_log.setLevel(logging.ERROR)

*************
Expand Down
12 changes: 4 additions & 8 deletions shotgun_api3/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def __init__(self, sg: "Shotgun"):
# In the case that the environment variable is already set, setting the
# property on the config will override it.
self.rpc_attempt_interval = 3000
# From http://docs.python.org/2.6/library/httplib.html:

# From https://docs.python.org/3.9/library/http.client.html:
# If the optional timeout parameter is given, blocking operations
# (like connection attempts) will timeout after that many seconds
# (if it is not given, the global default timeout setting is used)
Expand Down Expand Up @@ -3981,12 +3982,7 @@ def _make_upload_request(
Open the given request object, return the
response, raises URLError on protocol errors.
"""
try:
result = opener.open(request)

except urllib.error.HTTPError:
raise
return result
return opener.open(request)

def _parse_http_status(self, status: tuple) -> None:
"""
Expand Down Expand Up @@ -4480,7 +4476,7 @@ def _upload_data_to_storage(
:param str content_type: Content type of the data stream.
:param int size: Number of bytes in the data stream.
:param str storage_url: Target URL for the uploaded file.
:returns: upload url.
:returns: etag of the uploaded file (hash of the file content).
:rtype: str
"""

Expand Down