Skip to content

Commit 0e06cf1

Browse files
committed
Add examples using formatter
1 parent 8ae1844 commit 0e06cf1

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

README.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,37 @@ Installation
1313
1414
Example
1515
-------
16+
Simple
17+
''''''
1618
.. code-block:: python
1719
1820
import logging
19-
from slack_logger import SlackHandler
21+
from slack_logger import SlackHandler, SlackFormatter
2022
2123
sh = SlackHandler('YOUR_WEB_HOOK_URL') # url is like 'https://hooks.slack.com/...'
24+
sh.setFormatter(SlackFormatter())
2225
logging.basicConfig(handlers=[sh])
2326
logging.warning('warn message')
2427
28+
Using logger
29+
''''''''''''
30+
.. code-block:: python
31+
32+
import logging
33+
from slack_logger import SlackHandler, SlackFormatter
34+
2535
logger = logging.getLogger(__name__)
36+
logger.setLevel(logging.DEBUG)
37+
2638
sh = SlackHandler(username='logger', icon_emoji=':robot_face:', url='YOUR_WEB_HOOK_URL')
39+
sh.setLevel(logging.DEBUG)
40+
41+
f = SlackFormatter()
42+
sh.setFormatter(f)
2743
logger.addHandler(sh)
28-
logger.warn('warn message')
2944
30-
Next step
31-
---------
32-
Making formatter for better representation in Slack
45+
logger.debug('debug message')
46+
logger.info('info message')
47+
logger.warn('warn message')
48+
logger.error('error message')
49+
logger.critical('critical message')

0 commit comments

Comments
 (0)