https://github.com/activestate/recipe-577968-log-watcher-tail-f-log
Log Watcher (tAIL -f *.log)
https://github.com/activestate/recipe-577968-log-watcher-tail-f-log
learning learning-by-doing learning-python recipes snippets
Last synced: 4 months ago
JSON representation
Log Watcher (tAIL -f *.log)
- Host: GitHub
- URL: https://github.com/activestate/recipe-577968-log-watcher-tail-f-log
- Owner: ActiveState
- License: mit
- Created: 2019-10-10T15:29:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-08T20:41:59.000Z (over 5 years ago)
- Last Synced: 2025-01-09T10:30:39.159Z (6 months ago)
- Topics: learning, learning-by-doing, learning-python, recipes, snippets
- Language: Python
- Homepage: https://code.activestate.com/recipes/577968/
- Size: 12.7 KB
- Stars: 1
- Watchers: 24
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
This repository covers the following recipe from code.activestate.com:
[LOG WATCHER (TAIL -F *.LOG)
](https://code.activestate.com/recipes/577968/)*Created by Giampaolo Rodolà on Tue, 29 Nov 2011*
A python class which "watches" a directory and calls a callback(filename, lines) function every time one of the files being watched gets written, in real time.
Practically speaking, this can be compared to "tail -F *.log" UNIX command, but instead of having lines printed to stdout a python function gets called.
Similarly to tail, it takes care of "watching" new files which are created after initialization and "unwatching" those ones which are removed in the meantime. This means you'll be able to "follow" and support also rotating log files.
## Usage
If you already have the [State Tool] installed you can simply run
```
state activate ActiveState-Recipes/recipe-577968-log-watcher-tail-f-log
```If you do not have the [State Tool] installed you can use the following convenient one-liner.
Linux:
```
sh <(curl -q https://platform.activestate.com/dl/cli/install.sh) -n -f && state activate --path $HOME/ActiveState-Recipes/recipe-577968-log-watcher-tail-f-log ActiveState-Recipes/recipe-577968-log-watcher-tail-f-log
```Windows:
```
powershell "Set-Item -Path Env:NOPROMPT_INSTALL -Value 'true'; IEX(New-Object Net.WebClient).downloadString('https://platform.activestate.com/dl/cli/install.ps1')" && state activate --path %APPDATA%/ActiveState-Recipes/recipe-577968-log-watcher-tail-f-log ActiveState-Recipes/recipe-577968-log-watcher-tail-f-log
```macOS: not yet supported
[State Tool]: https://www.activestate.com/products/platform/state-tool/
### Advanced Usage
See [original recipe](https://code.activestate.com/recipes/577968/) for advanced usage information