mtnlog


Namemtnlog JSON
Version 1.2.17 PyPI version JSON
download
home_pagehttps://github.com/kentakoong/mtnlog
SummaryA simple performance logger for Python
upload_time2024-09-24 07:21:54
maintainerNone
docs_urlNone
authorWongkraiwich Chuenchomphu
requires_python>=3.9
licenseMIT
keywords performance logging python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mtnlog - A simple multinode performance logger for Python

## Introduction

mtnlog is a simple multinode performance logger for Python. It is designed to be used in a similar way to Python's built-in logging module, but with a focus on performance logging. It provides a simple API for logging performance data, including start and end times, and allows for easy integration with other logging systems.

## Installation

You can install mtnlog using pip:

```bash
pip install mtnlog
```

## Usage

To use mtnlog, you have two features: `JSONLogger` and `PerformanceLogger` and `PerformancePlotter`.

### JSONLogger

The `JSONLogger` class is a simple logger that writes performance data to a JSON file. You can create a new `JSONLogger` instance by passing a file path to the constructor:

```python
from mtnlog import JSONLogger

logger = JSONLogger(log_dir='logs') # logs is the directory where the log file will be saved
```

You can then use the `log` method to log performance data:

```python
logger.log('<your_dict>', filename='log') # your_dict is a dictionary with the data you want to log / filename is the name of the file
```

`your_dict` is a dictionary with the data you want to log.
`filename` is the name of the file where the data will be saved

### PerformanceLogger

The `PerformanceLogger` class is a logger for system performance data. It logs the the time taken to execute the block, as well as the CPU, memory, and GPU usage. You can create a new `PerformanceLogger` instance by passing a file path to the constructor:

```python
from mtnlog import PerformanceLogger

collector = PerformanceLogger(log_dir="<your_log_dir>", log_node="<current_node>")
```

`your_log_dir` is the directory where the log file will be saved.
`current_node` is the number of the node you are logging.

You can then use the `change_tag` method to change the tag of the log:

```python
collector.change_tag("<new_tag>")
```

`new_tag` is the new tag you want to use.

To stop logging, you can use the `stop` method:

```python
collector.stop()
```

### PerformancePlotter

The `PerformancePlotter` class is a plotter for system performance data. It plots the time taken to execute the block, as well as the CPU, memory, GPU, and network usage. You can create a new `PerformancePlotter` instance by passing a file path to the constructor:

```python
from mtnlog import PerformancePlotter

plotter = PerformancePlotter(base_dir="<your_base_dir>", log_node="<current_node>")

```

`your_base_dir` is the base directory where the log file will be saved.
`current_node` is the number of the node you are logging.

You can then use the `plot` method to plot the data:

```python

plotter.plot()

```

## Example

Here is an example of how to use mtnlog:

```python
from mtnlog import JSONLogger, PerformanceLogger, PerformancePlotter

# Create a JSONLogger instance

logger = JSONLogger(log_dir='logs')

# Log some data

logger.log({'message': 'Hello, world!'}, filename='log')

# Create a PerformanceLogger instance

collector = PerformanceLogger(log_dir='logs', log_node="0")

# Change the tag

collector.change_tag('new_tag')

# Stop logging

collector.stop()

# Create a PerformancePlotter instance

plotter = PerformancePlotter(base_dir='logs', log_node="0")

# Plot the data

plotter.plot()

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kentakoong/mtnlog",
    "name": "mtnlog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "performance, logging, python",
    "author": "Wongkraiwich Chuenchomphu",
    "author_email": "wongkraiwich@inedible.dev",
    "download_url": "https://files.pythonhosted.org/packages/a1/1a/ed8afec3126c3f5ba296b6660be4b82670b6f7a03a64ef611ca4b4252063/mtnlog-1.2.17.tar.gz",
    "platform": null,
    "description": "# mtnlog - A simple multinode performance logger for Python\n\n## Introduction\n\nmtnlog is a simple multinode performance logger for Python. It is designed to be used in a similar way to Python's built-in logging module, but with a focus on performance logging. It provides a simple API for logging performance data, including start and end times, and allows for easy integration with other logging systems.\n\n## Installation\n\nYou can install mtnlog using pip:\n\n```bash\npip install mtnlog\n```\n\n## Usage\n\nTo use mtnlog, you have two features: `JSONLogger` and `PerformanceLogger` and `PerformancePlotter`.\n\n### JSONLogger\n\nThe `JSONLogger` class is a simple logger that writes performance data to a JSON file. You can create a new `JSONLogger` instance by passing a file path to the constructor:\n\n```python\nfrom mtnlog import JSONLogger\n\nlogger = JSONLogger(log_dir='logs') # logs is the directory where the log file will be saved\n```\n\nYou can then use the `log` method to log performance data:\n\n```python\nlogger.log('<your_dict>', filename='log') # your_dict is a dictionary with the data you want to log / filename is the name of the file\n```\n\n`your_dict` is a dictionary with the data you want to log.\n`filename` is the name of the file where the data will be saved\n\n### PerformanceLogger\n\nThe `PerformanceLogger` class is a logger for system performance data. It logs the the time taken to execute the block, as well as the CPU, memory, and GPU usage. You can create a new `PerformanceLogger` instance by passing a file path to the constructor:\n\n```python\nfrom mtnlog import PerformanceLogger\n\ncollector = PerformanceLogger(log_dir=\"<your_log_dir>\", log_node=\"<current_node>\")\n```\n\n`your_log_dir` is the directory where the log file will be saved.\n`current_node` is the number of the node you are logging.\n\nYou can then use the `change_tag` method to change the tag of the log:\n\n```python\ncollector.change_tag(\"<new_tag>\")\n```\n\n`new_tag` is the new tag you want to use.\n\nTo stop logging, you can use the `stop` method:\n\n```python\ncollector.stop()\n```\n\n### PerformancePlotter\n\nThe `PerformancePlotter` class is a plotter for system performance data. It plots the time taken to execute the block, as well as the CPU, memory, GPU, and network usage. You can create a new `PerformancePlotter` instance by passing a file path to the constructor:\n\n```python\nfrom mtnlog import PerformancePlotter\n\nplotter = PerformancePlotter(base_dir=\"<your_base_dir>\", log_node=\"<current_node>\")\n\n```\n\n`your_base_dir` is the base directory where the log file will be saved.\n`current_node` is the number of the node you are logging.\n\nYou can then use the `plot` method to plot the data:\n\n```python\n\nplotter.plot()\n\n```\n\n## Example\n\nHere is an example of how to use mtnlog:\n\n```python\nfrom mtnlog import JSONLogger, PerformanceLogger, PerformancePlotter\n\n# Create a JSONLogger instance\n\nlogger = JSONLogger(log_dir='logs')\n\n# Log some data\n\nlogger.log({'message': 'Hello, world!'}, filename='log')\n\n# Create a PerformanceLogger instance\n\ncollector = PerformanceLogger(log_dir='logs', log_node=\"0\")\n\n# Change the tag\n\ncollector.change_tag('new_tag')\n\n# Stop logging\n\ncollector.stop()\n\n# Create a PerformancePlotter instance\n\nplotter = PerformancePlotter(base_dir='logs', log_node=\"0\")\n\n# Plot the data\n\nplotter.plot()\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple performance logger for Python",
    "version": "1.2.17",
    "project_urls": {
        "Documentation": "https://github.com/kentakoong/mtnlog",
        "Homepage": "https://github.com/kentakoong/mtnlog",
        "Issues": "https://github.com/kentakoong/mtnlog/issues",
        "Repository": "https://github.com/kentakoong/mtnlog"
    },
    "split_keywords": [
        "performance",
        " logging",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b4a24912149d12b9ebecb910087957847a81a2719c4c00563a595b7710a5326",
                "md5": "4d679d921e6bc60d303af4a856ec89b9",
                "sha256": "8c57568fae8aa0ecd18d7b59b47ee8a04f13d22f847ec9a4ab1b258529285e6d"
            },
            "downloads": -1,
            "filename": "mtnlog-1.2.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4d679d921e6bc60d303af4a856ec89b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 12449,
            "upload_time": "2024-09-24T07:21:52",
            "upload_time_iso_8601": "2024-09-24T07:21:52.806461Z",
            "url": "https://files.pythonhosted.org/packages/0b/4a/24912149d12b9ebecb910087957847a81a2719c4c00563a595b7710a5326/mtnlog-1.2.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a11aed8afec3126c3f5ba296b6660be4b82670b6f7a03a64ef611ca4b4252063",
                "md5": "34f1f07942532bc9a972a37b4ff17ef4",
                "sha256": "62ae30f041bc62b390fa1cc45533d05a007f62cd8aa1dacd6edf532e21aeffec"
            },
            "downloads": -1,
            "filename": "mtnlog-1.2.17.tar.gz",
            "has_sig": false,
            "md5_digest": "34f1f07942532bc9a972a37b4ff17ef4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11752,
            "upload_time": "2024-09-24T07:21:54",
            "upload_time_iso_8601": "2024-09-24T07:21:54.179324Z",
            "url": "https://files.pythonhosted.org/packages/a1/1a/ed8afec3126c3f5ba296b6660be4b82670b6f7a03a64ef611ca4b4252063/mtnlog-1.2.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-24 07:21:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kentakoong",
    "github_project": "mtnlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mtnlog"
}
        
Elapsed time: 0.38202s