Skip to content

Commit 822eab7

Browse files
committed
Update README
1 parent 078105f commit 822eab7

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

README.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Many web/mobile applications generate huge amount of event logs (c,f. login, log
1717

1818
This library is distributed as 'fluent-logger' python package. Please execute the following command to install it.
1919

20-
$ pip install fluent-logger
20+
```sh
21+
$ pip install fluent-logger
22+
```
2123

2224
## Configuration
2325

@@ -42,38 +44,44 @@ First, you need to call `logger.setup()` to create global logger instance. This
4244

4345
By default, the logger assumes fluentd daemon is launched locally. You can also specify remote logger by passing the options.
4446

45-
from fluent import sender
46-
47-
# for local fluent
48-
sender.setup('app')
49-
50-
# for remote fluent
51-
sender.setup('app', host='host', port=24224)
47+
```python
48+
from fluent import sender
49+
50+
# for local fluent
51+
sender.setup('app')
52+
53+
# for remote fluent
54+
sender.setup('app', host='host', port=24224)
55+
```
5256

5357
Then, please create the events like this. This will send the event to fluent, with tag 'app.follow' and the attributes 'from' and 'to'.
5458

55-
from fluent import event
59+
```python
60+
from fluent import event
5661

57-
# send event to fluentd, with 'app.follow' tag
58-
event.Event('follow', {
59-
'from': 'userA',
60-
'to': 'userB'
61-
})
62+
# send event to fluentd, with 'app.follow' tag
63+
event.Event('follow', {
64+
'from': 'userA',
65+
'to': 'userB'
66+
})
67+
```
6268

6369
### Python logging.Handler interface
6470

6571
This client-library also has `FluentHandler` class for Python logging module.
6672

67-
import logging
68-
from fluent import handler
69-
70-
logging.basicConfig(level=logging.INFO)
71-
l = logging.getLogger('fluent.test')
72-
l.addHandler(handler.FluentHandler('app.follow', host='host', port=24224))
73-
l.info({
74-
'from': 'userA',
75-
'to': 'userB'
76-
})
73+
```python
74+
import logging
75+
from fluent import handler
76+
77+
logging.basicConfig(level=logging.INFO)
78+
l = logging.getLogger('fluent.test')
79+
l.addHandler(handler.FluentHandler('app.follow', host='host', port=24224))
80+
l.info({
81+
'from': 'userA',
82+
'to': 'userB'
83+
})
84+
```
7785

7886
## Testing
7987

0 commit comments

Comments
 (0)