forked from kasun/python-tail
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample1.py
More file actions
Latest commit
24 lines (17 loc) · 511 Bytes
/
Copy pathexample1.py
File metadata and controls
24 lines (17 loc) · 511 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
'''
python-tail example.
Does a tail follow against /var/log/syslog with a time interval of 5 seconds.
Prints recieved new lines to standard out '''
importtail
history= {'filename' : ''}
defprint_line(txt, filename):
''' Prints received text '''
globalhistory
ifhistory['filename'] !=filename:
txt="===> "+filename+" <===\n"+txt
history['filename'] =filename
printtxt.strip("\n")
t=tail.Tail(['/var/log/syslog'])
t.register_callback(print_line, 1)
t.follow(10)