Skip to main content

watchlog

watchlog is a Python package for monitoring log files and sending parsed logs to a specified URL using HTTP POST requests.

Installation

You can install watchlog using pip:

pip install watchlog

Usage

To use watchlog, you need to create a configuration file in JSON format. Here is an example configuration file:

{
  "check_interval": 5,
  "check": true,
  "files": [
    {
      "path": "/path/to/log/file.log",
      "reg": "^(?P<time>[^ ]*) (?P<level>[^ ]*) (?P<module>[^ ]*) (?P<line>[^ ]*) (?P<message>.*)$",
      "url": "http://example.com/api/logs",
      "latest": true,
      "enable": true,
      "headers": {
        "Content-Type": "application/json"
      },
      "auth": {
        "username": "user",
        "password": "pass"
      }
    }
  ]
}
  • path: The path of the log file to monitor.
  • reg: A regular expression used to parse the log file.
  • url: The URL to send the parsed logs to.
  • latest: Start monitoring from the latest logs.
  • enable: Indicates that this configuration will be enabled, which defaults to true.
  • headers: A dictionary of headers to include in the HTTP POST request.
  • auth: A dictionary with username and password keys for basic authentication.
  • check: if open check ,it will loop check the config file
  • check_interval: circle check interval time(s)

Once you have created the configuration file, you can start monitoring the log file by calling the start() function from the watchlog module:

import asyncio
from watchlog import start

loop = asyncio.get_event_loop()
loop.run_until_complete(start('path/to/config.json'))

You can also use we provide small scripts

watchlog path/to/config/file

This will start monitoring the log file specified in the configuration file and sending parsed logs to the specified URL using HTTP POST requests.

example

example use zinc_observe as log search_engine,Illustrates the use of the process

.                     
├── __init__.py       
├── config.json             config file
├── docker-compose.yml      log search engine service
├── log.log                 log file
└── main.py                 main python file to monitor log file

License

watchlog is licensed under the MIT license.

Metadata

Release files for watchlog 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for watchlog 0.1.2
File Size Uploaded Provenance Actions
watchlog-0.1.2.tar.gz 5.1 kB Without provenance Details for watchlog-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for watchlog 0.1.2
File Interpreter ABI Platform Actions
watchlog-0.1.2-py3-none-any.whl Python 3 none any Details for watchlog-0.1.2-py3-none-any.whl

Total release size: 11.1 kB

Release files / watchlog-0.1.2.tar.gz

Download URL watchlog-0.1.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e5865f45e981d82555c3e1d790d7d760c9b07264126eb3295c5b3578f9ddb233
BLAKE2b-256 checksum
How to use checksums
3585fe110fe762897d1a35a0d2d7d625e2be00c6b33aa6b4331532d44a52aee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.8.10 Linux/5.15.90.1-microsoft-standard-WSL2

Release files / watchlog-0.1.2-py3-none-any.whl

Download URL watchlog-0.1.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0412214b35abfb89bcaf89e8d156e880bf874eb2af481dd5000c0e849fb10f4
BLAKE2b-256 checksum
How to use checksums
2adf2a104435eda6a0136944bee788e1503e2acff18024fb9eee3c5361d567c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.8.10 Linux/5.15.90.1-microsoft-standard-WSL2

Security for watchlog 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page