项目作者: ActiveState

项目描述 :
Log Watcher (tAIL -f *.log)
高级语言: Python
项目地址: git://github.com/ActiveState/recipe-577968-log-watcher-tail-f-log.git
创建时间: 2019-10-10T15:29:15Z
项目社区:https://github.com/ActiveState/recipe-577968-log-watcher-tail-f-log

开源协议:MIT License

下载


This repository covers the following recipe from code.activestate.com:

LOG WATCHER (TAIL -F *.LOG)

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

  1. 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:

  1. 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:

  1. 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

Advanced Usage

See original recipe for advanced usage information