读取尚未读取的日志文件行。

pygtail的Python项目详细描述


python的logcheck’s logtail2端口。

pygtail读取尚未读取的日志文件行。它甚至会 处理已旋转的日志文件。

用法

从命令行:

Usage: pygtail.py [options] logfile

Print log file lines that have not been read.

Options:
  -h, --help            show this help message and exit
  -o OFFSET_FILE, --offset-file=OFFSET_FILE
                        File to which offset data is written (default:
                        <logfile>.offset).
  -p, --paranoid        Update the offset file every time we read a line
                        (as opposed to only when we reach the end of the
                        file).
  -n N, --every-n=N     Update the offset file every N'th time we read a
                        line (as opposed to only when we reach the end of
                        the file).
  --no-copytruncate     Don't support copytruncate-style log rotation.
                        Instead, if the log file shrinks, print a warning.
  --read-from-end       Read log file from the end if offset file is
                        missing. Useful for large files.
  --log-pattern         Custom log rotation glob pattern. Use %s to
                        represent the original filename. You may use this
                        multiple times to provide multiple patterns.
  --full_lines          Only log when line ends in a newline `\n`
                        (default: False)
  --version             Print version and exit.

在您的代码中:

frompygtailimportPygtailforlineinPygtail("some.log"):sys.stdout.write(line)

贡献

拉取请求非常受欢迎,但如果您不包括测试,我不会合并您的更改。使用python setup.py test运行测试。

生成状态

Build Status

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在一个问题被连续正确回答三次/并添加差异后,我如何将程序循环回开始   Java中未实例化的匿名类   java如何在Android中录制视频,只允许横向模式和最长时间录制时间   java从另一个活动发送实时消息   多线程java线程和互斥   java禁用Spring安全日志   JAVA伊奥。StreamCorruptedException:在与子级和父级ProcessBuilder通信时写入子级中的标准输出时,流头无效   使用Java(HttpURLConnection)对Restheart进行身份验证(对于Mongodb)   java如何解决Jenkins中的SAXParseException?   java为什么我需要mockito来测试Spring应用程序?   计算sin-cos和tan时缺乏精度(java)   java Hibernate。不同项目中相同一对一映射的不同行为   java图像滑块:如何使用JavaFX将图像放在另一个图像上   java Mockito在使用when时抛出NotAMockException   http Java servlet发送回响应