8000 docs: add debug logging example (#544) · Atharva2011/twilio-python@faf60df · GitHub
[go: up one dir, main page]

Skip to content

Commit faf60df

Browse files
docs: add debug logging example (twilio#544)
1 parent 8c1ca92 commit faf60df

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,28 @@ message = client.messages.create(to="+12316851234", from_="+15555555555",
137137
body="Hello there!")
138138
```
139139

140+
### Enable Debug Logging
141+
142+
Log the API request and response data to the console:
143+
144+
```python
145+
import logging
146+
147+
client = Client(account, token)
148+
logging.basicConfig()
149+
client.http_client.logger.setLevel(logging.INFO)
150+
```
151+
152+
Log the API request and response data to a file:
153+
154+
```python
155+
import logging
156+
157+
client = Client(account, token)
158+
logging.basicConfig(filename='./log.txt')
159+
client.http_client.logger.setLevel(logging.INFO)
160+
```
161+
140162
### Handling Exceptions
141163

142164
```python

0 commit comments

Comments
 (0)
0