-
-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window size config #1975
Window size config #1975
Changes from all commits
36c27d5
65fee54
c3be359
7ba2f03
2f4d3d9
c5fa92e
7710133
3001910
e4bb2ec
12ee566
c021795
1c4590b
91789a5
c9519e6
0f790df
ba1b87d
b8ee8e6
bf79ea2
c6a743c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,34 @@ Add the following to your code to log everything available: | |
logger.setLevel(logging.DEBUG) | ||
logger.addHandler(handler) | ||
|
||
Or you can use the following to write the logs to a file for longer running bots or | ||
scripts when you need to look back at what the bot did hours ago. | ||
|
||
.. code-block:: python | ||
|
||
import logging | ||
|
||
stream_handler = logging.StreamHandler() | ||
stream_handler.setLevel(logging.DEBUG) | ||
file_handler = logging.handlers.RotatingFileHandler( | ||
"praw_log.txt", maxBytes=1024 * 1024 * 16, backupCount=5 | ||
) | ||
file_handler.setLevel(logging.DEBUG) | ||
for logger_name in ("praw", "prawcore"): | ||
logger = logging.getLogger(logger_name) | ||
logger.setLevel(logging.DEBUG) | ||
logger.addHandler(stream_handler) | ||
logger.addHandler(file_handler) | ||
|
||
When properly configured, HTTP requests that are issued should produce output similar to | ||
the following: | ||
|
||
.. code-block:: text | ||
|
||
Fetching: GET https://oauth.reddit.com/api/v1/me | ||
Fetching: GET https://oauth.reddit.com/api/v1/me at 1691743155.4952002 | ||
Data: None | ||
Params: {'raw_json': 1} | ||
Response: 200 (876 bytes) | ||
Response: 200 (876 bytes) (rst-45:rem-892:used-104 ratelimit) at 1691743156.3847592 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is from prawcore but what do you think about changing the epoch to a timestamp? It would only be 1 or 2 more characters and would be human readable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this to match the timestamp in the first line. But no real opinion whether they should both be timestamps or a human readable date. |
||
|
||
Furthermore, any API ratelimits from POST actions that are handled will produce a log | ||
entry with a message similar to the following message: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be too advanced. Maybe add a second example explaining why you recommend a rotating file handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed