Skip to main content

A simple performance logger for Python

Project description

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:

pip install mtnlog

Usage

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

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:

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:

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:

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:

collector.change_tag("<new_tag>")

new_tag is the new tag you want to use.

To stop logging, you can use the stop method:

collector.stop()

Example

Here is an example of how to use mtnlog:

from mtnlog import JSONLogger, PerformanceLogger

# 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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtnlog-1.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

mtnlog-1.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file mtnlog-1.1.0.tar.gz.

File metadata

  • Download URL: mtnlog-1.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for mtnlog-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b75bd6f9a7e20913450d8c5f96b08c1692a890c6a166dc5046c56fe6a1d811e8
MD5 7ca899c9fe4cd464ba256be5624b78c2
BLAKE2b-256 ecfc034dc0fe4a0a55af001dbcde73a59961ccd2c0474a0b3448753d899d27d2

See more details on using hashes here.

File details

Details for the file mtnlog-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mtnlog-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for mtnlog-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0883c33e6f810078cc4ab33d481a393f7e6307a932c3d4f9e40959c9f2244216
MD5 d3621b1867fc2bd224a228f93109635e
BLAKE2b-256 daefcc3373c4f9df3e54777dbabc036873a20e3370f3bee637bb9a31d121bdec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page