Added a stream class for use with the logging module.
License assent: https://github.com/zulip/python-zulip/pull/3#issuecomment-18182458 (imported from commit 9faf9dd147032b1e56b113bc0f0d729a653e1e49)
This commit is contained in:
parent
b0f73806de
commit
fb5a3dc3d8
2 changed files with 39 additions and 0 deletions
17
README.md
17
README.md
|
@ -67,6 +67,23 @@ keys: msg, result. For successful calls, result will be "success" and
|
|||
msg will be the empty string. On error, result will be "error" and
|
||||
msg will describe what went wrong.
|
||||
|
||||
#### Logging
|
||||
The Zulip API comes with a ZulipStream class which can be used with the
|
||||
logging module:
|
||||
|
||||
```
|
||||
import zulip
|
||||
import logging
|
||||
stream = zulip.ZulipStream(type="stream", to=["support"], subject="your subject")
|
||||
logger = logging.getLogger("your_logger")
|
||||
logger.addHandler(logging.StreamHandler(stream))
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.info("This is an INFO test.")
|
||||
logger.debug("This is a DEBUG test.")
|
||||
logger.warn("This is a WARN test.")
|
||||
logger.error("This is a ERROR test.")
|
||||
```
|
||||
|
||||
#### Sending messages
|
||||
|
||||
You can use the included `zulip-send` script to send messages via the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue