Skip to content
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

Implement proper logging #16

Open
AlexBurkey opened this issue May 31, 2020 · 0 comments
Open

Implement proper logging #16

AlexBurkey opened this issue May 31, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@AlexBurkey
Copy link
Owner

Is your feature request related to a problem? Please describe.
Currently all "logs" are just print statements to stdout. Use a proper logger so that crashes and exceptions get sent to one spot while tracking of responses goes to a different log.

Describe the solution you'd like
A separation of crashes like:

  File "bot.py", line 259, in <module>
    for comment in r.subreddit(SUBREDDIT_NAME).stream.comments():
  File "/home/pi/.local/lib/python3.7/site-packages/praw/models/util.py", line 186, in stream_generator
    for item in reversed(list(function(limit=limit, **function_kwargs))):
  File "/home/pi/.local/lib/python3.7/site-packages/praw/models/listing/generator.py", line 61, in __next__
    self._next_batch()
  File "/home/pi/.local/lib/python3.7/site-packages/praw/models/listing/generator.py", line 71, in _next_batch
    self._listing = self._reddit.get(self.url, params=self.params)
  File "/home/pi/.local/lib/python3.7/site-packages/praw/reddit.py", line 490, in get
    return self._objectify_request(method="GET", params=params, path=path)
  File "/home/pi/.local/lib/python3.7/site-packages/praw/reddit.py", line 574, in _objectify_request
    data=data, files=files, method=method, params=params, path=path
  File "/home/pi/.local/lib/python3.7/site-packages/praw/reddit.py", line 732, in request
    timeout=self.config.timeout,
  File "/home/pi/.local/lib/python3.7/site-packages/prawcore/sessions.py", line 336, in request
    url=url,
  File "/home/pi/.local/lib/python3.7/site-packages/prawcore/sessions.py", line 262, in _request_with_retries
    url,
  File "/home/pi/.local/lib/python3.7/site-packages/prawcore/sessions.py", line 170, in _do_retry
    retry_strategy_state=retry_strategy_state.consume_available_retry(),  # noqa: E501
  File "/home/pi/.local/lib/python3.7/site-packages/prawcore/sessions.py", line 262, in _request_with_retries
    url,
  File "/home/pi/.local/lib/python3.7/site-packages/prawcore/sessions.py", line 170, in _do_retry
    retry_strategy_state=retry_strategy_state.consume_available_retry(),  # noqa: E501
  File "/home/pi/.local/lib/python3.7/site-packages/prawcore/sessions.py", line 265, in _request_with_retries
    raise self.STATUS_EXCEPTIONS[response.status_code](response)
prawcore.exceptions.ServerError: received 503 HTTP response

From normal log messages like:

Setting up DB...
Done!
Looking for comments...
Comment hash: fscc3yb
Request url: https://api.imgur.com/3/album/MqT99lp/images
Image link: https://i.imgur.com/OoXu0jY.jpg
Hash: fscc3yb
Has responded: True
Response type: op
Comment Body: 
b'!MFAImageBot op 33\n\nLets see if this works...'
Tokens: [b'!MFAImageBot', b'op', b'33', b'Lets', b'see', b'if', b'this', b'works...']
Response comment body: 
b'[#33](https://i.imgur.com/OoXu0jY.jpg)  \nImage number 33 from album https://imgur.com/a/MqT99lp'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All that's probably needed is just to change the print statements into logger stuff but I want to make sure I understand where the output and stuff is going.

@AlexBurkey AlexBurkey added the enhancement New feature or request label May 31, 2020
@AlexBurkey AlexBurkey self-assigned this May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant