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

Add logging #5

Open
surfer190 opened this issue May 9, 2019 · 1 comment
Open

Add logging #5

surfer190 opened this issue May 9, 2019 · 1 comment

Comments

@surfer190
Copy link
Contributor

To prevent unhelpful error messages like this:

[cent@st2 kafka]$ st2 run kafka.produce topic='test' message='Hello from stackstorm'
.
id: 5cd40d3152364c11e30049b3
status: failed
parameters: 
  message: Hello from stackstorm
  topic: test
result: 
  exit_code: 1
  result: None
  stderr: "No handlers could be found for logger "kafka.conn"
Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/python_runner/python_action_wrapper.py", line 334, in <module>
    obj.run()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/python_runner/python_action_wrapper.py", line 193, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/kafka/actions/produce.py", line 42, in run
    result = producer.send_messages(topic, kafka_bytestring(message))
  File "/opt/stackstorm/virtualenvs/kafka/lib/python2.7/site-packages/kafka/producer/simple.py", line 54, in send_messages
    topic, partition, *msg
  File "/opt/stackstorm/virtualenvs/kafka/lib/python2.7/site-packages/kafka/producer/base.py", line 364, in send_messages
    return self._send_messages(topic, partition, *msg)
  File "/opt/stackstorm/virtualenvs/kafka/lib/python2.7/site-packages/kafka/producer/base.py", line 411, in _send_messages
    fail_on_error=self.sync_fail_on_error
  File "/opt/stackstorm/virtualenvs/kafka/lib/python2.7/site-packages/kafka/client.py", line 614, in send_produce_request
    (not fail_on_error or not self._raise_on_response_error(resp))]
  File "/opt/stackstorm/virtualenvs/kafka/lib/python2.7/site-packages/kafka/client.py", line 374, in _raise_on_response_error
    raise resp
kafka.common.FailedPayloadsError
"
  stdout: ''

Could we add a logger to catch and give useful information like that described in this kafka stackoverflow logger not found answer.

It helped quite a bit:

import logging
logging.basicConfig(
    format='%(asctime)s.%(msecs)s:%(name)s:%(thread)d:%(levelname)s:%(process)d:%(message)s',
    level=logging.DEBUG
)
@arm4b
Copy link
Member

arm4b commented May 9, 2019

Contributions to improve error reporting and catch unreadable errors like that are definitely welcome!

If you could workaround that particular case and utilize ST2 logger (https://docs.stackstorm.com/actions.html#logging) or just re-throw more user-friendly error message that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants