Errors and utilities
Logging
The SDK logs through the standard logging module, to the nace_sdk logger, which has only a NullHandler. Nothing prints until your app configures a handler, and you choose the level with NACE_LOG_LEVEL or setLevel:
import logging
logging.basicConfig() # a stderr handler
logging.getLogger("nace_sdk").setLevel(logging.INFO)NACE_LOG_LEVEL is read once, when nace_sdk is first imported. It takes debug, info, warn, warning, error or off, in any case; anything else is ignored.
| Level | What it logs |
|---|---|
info | One line per request, except streamed calls (below): method, URL, status, duration and x-request-id. Each retry and each failed connection. |
debug | Also the headers and JSON body of each request and response. A body that isn't JSON, such as a file part, shows only its size. |
warning | Answers of an unknown type that were dropped. |
Streamed calls log nothing, not even their retries, except an info line when their connection fails. They are jobs.events, jobs.file_link, and jobs.download with its fetch of a signed link.
Before any record reaches a handler, the SDK masks with *** the headers Authorization, Proxy-Authorization, X-Api-Key, Api-Key, X-Upload-Token, Cookie and Set-Cookie, any header whose name contains token or secret, and the body fields token, session_token and password. Connection errors are logged and raised with your credentials masked. URLs are logged as sent, query included, so a signed link's failed fetch logs the link.