watchlog


Namewatchlog JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/Euraxluo/watchlog
Summarymonitoring log files and sending parsed logs to a specified URL
upload_time2023-05-22 02:03:12
maintainer
docs_urlNone
authoreuraxluo
requires_python>=3.8,<4.0
licenseThe MIT LICENSE
keywords log monitor loguru watchdog
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # watchlog

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

- name = "watchlog"
- description = "monitoring log files and sending parsed logs to a specified URL"
- authors = ["Euraxluo <euraxluo@outlook.com>"]
- license = "The MIT LICENSE"
- repository = "https://github.com/Euraxluo/watchlog"
- version = "0.1.*"

## Installation

You can install `watchlog` using pip:

```bash
pip install watchlog
```

## Usage

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

```json
{
  "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:

```python
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

```bash
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.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Euraxluo/watchlog",
    "name": "watchlog",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "log monitor,loguru,watchdog",
    "author": "euraxluo",
    "author_email": "euraxluo@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/35/85/fe110fe762897d1a35a0d2d7d625e2be00c6b33aa6b4331532d44a52aee1/watchlog-0.1.2.tar.gz",
    "platform": null,
    "description": "# watchlog\n\n`watchlog` is a Python package for monitoring log files and sending parsed logs to a specified URL using HTTP POST\nrequests.\n\n- name = \"watchlog\"\n- description = \"monitoring log files and sending parsed logs to a specified URL\"\n- authors = [\"Euraxluo <euraxluo@outlook.com>\"]\n- license = \"The MIT LICENSE\"\n- repository = \"https://github.com/Euraxluo/watchlog\"\n- version = \"0.1.*\"\n\n## Installation\n\nYou can install `watchlog` using pip:\n\n```bash\npip install watchlog\n```\n\n## Usage\n\nTo use `watchlog`, you need to create a configuration file in JSON format. Here is an example configuration file:\n\n```json\n{\n  \"check_interval\": 5,\n  \"check\": true,\n  \"files\": [\n    {\n      \"path\": \"/path/to/log/file.log\",\n      \"reg\": \"^(?P<time>[^ ]*) (?P<level>[^ ]*) (?P<module>[^ ]*) (?P<line>[^ ]*) (?P<message>.*)$\",\n      \"url\": \"http://example.com/api/logs\",\n      \"latest\": true,\n      \"enable\": true,\n      \"headers\": {\n        \"Content-Type\": \"application/json\"\n      },\n      \"auth\": {\n        \"username\": \"user\",\n        \"password\": \"pass\"\n      }\n    }\n  ]\n}\n```\n\n- `path`: The path of the log file to monitor.\n- `reg`: A regular expression used to parse the log file.\n- `url`: The URL to send the parsed logs to.\n- `latest`: Start monitoring from the latest logs.\n- `enable`: Indicates that this configuration will be enabled, which defaults to true.\n- `headers`: A dictionary of headers to include in the HTTP POST request.\n- `auth`: A dictionary with `username` and `password` keys for basic authentication.\n- `check`: if open check ,it will loop check the config file\n- `check_interval`: circle check interval time(s)\n\nOnce you have created the configuration file, you can start monitoring the log file by calling the `start()` function\nfrom the `watchlog` module:\n\n```python\nimport asyncio\nfrom watchlog import start\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(start('path/to/config.json'))\n```\n\nYou can also use we provide small scripts\n\n```bash\nwatchlog path/to/config/file\n```\n\nThis will start monitoring the log file specified in the configuration file and sending parsed logs to the specified URL\nusing HTTP POST requests.\n\n## example\n\nexample use zinc_observe as log search_engine,Illustrates the use of the process\n\n```\n.                     \n\u251c\u2500\u2500 __init__.py       \n\u251c\u2500\u2500 config.json             config file\n\u251c\u2500\u2500 docker-compose.yml      log search engine service\n\u251c\u2500\u2500 log.log                 log file\n\u2514\u2500\u2500 main.py                 main python file to monitor log file\n```\n\n## License\n\n`watchlog` is licensed under the MIT license.",
    "bugtrack_url": null,
    "license": "The MIT LICENSE",
    "summary": "monitoring log files and sending parsed logs to a specified URL",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/Euraxluo/watchlog",
        "Repository": "https://github.com/Euraxluo/watchlog"
    },
    "split_keywords": [
        "log monitor",
        "loguru",
        "watchdog"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2adf2a104435eda6a0136944bee788e1503e2acff18024fb9eee3c5361d567c2",
                "md5": "f4643523d019b2fb6c4671858dff60df",
                "sha256": "d0412214b35abfb89bcaf89e8d156e880bf874eb2af481dd5000c0e849fb10f4"
            },
            "downloads": -1,
            "filename": "watchlog-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4643523d019b2fb6c4671858dff60df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5984,
            "upload_time": "2023-05-22T02:03:11",
            "upload_time_iso_8601": "2023-05-22T02:03:11.217381Z",
            "url": "https://files.pythonhosted.org/packages/2a/df/2a104435eda6a0136944bee788e1503e2acff18024fb9eee3c5361d567c2/watchlog-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3585fe110fe762897d1a35a0d2d7d625e2be00c6b33aa6b4331532d44a52aee1",
                "md5": "a081401e518beaa2658dabe5efe1d5cf",
                "sha256": "e5865f45e981d82555c3e1d790d7d760c9b07264126eb3295c5b3578f9ddb233"
            },
            "downloads": -1,
            "filename": "watchlog-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a081401e518beaa2658dabe5efe1d5cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 5134,
            "upload_time": "2023-05-22T02:03:12",
            "upload_time_iso_8601": "2023-05-22T02:03:12.831178Z",
            "url": "https://files.pythonhosted.org/packages/35/85/fe110fe762897d1a35a0d2d7d625e2be00c6b33aa6b4331532d44a52aee1/watchlog-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-22 02:03:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Euraxluo",
    "github_project": "watchlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "watchlog"
}
        
Elapsed time: 0.09536s