Skip to main content

provides a standardised, easy to import and use logging method with mcap

Project description

MCAP Logger 🧢

This python package wraps the MCap protobuf logging package with the Foxglove schemas to provide a standardised, easy to import and use logging method.

Usage

  1. Add the package to your python project.
  2. Import the package and use the get_logger function to create your logger.
from mcap_logger.mcap_logger import get_logger

logger = get_logger(__name__)
  1. If you haven't provided any log file path and or log level to the get_logger function, you can use environmental variables to specify them at run time. LOG_LEVEL for log level, and LOG_ROOT for the log file.
LOG_LEVEL=DEBUG LOG_ROOT=log_file.mcap uv run python -m mcap.demo.demo
  1. Use the MCAPLogger .debug(), .info(), .warning(), etc. functions to create different types of log messages
  2. If you want to log topics like sensor data, you have to first specify the message with protobuf. (See the Working with ProtoBuf section).
  3. You can open the created log file with Foxglove Studio.

For an example see demo.py.

The output: demo_log_in_foxglove.png

Working with ProtoBuf

Protocol buffers are Google's language-neutral mechanism for serializing structured data.

ℹ️ More info about it and its syntax: Protocol Buffers

  1. Make sure that you have the latest protobuf-compiler installed protoc installation
  2. You can compile the .proto file with the following command.

Example:

protoc --python_out=. sensor_data.proto
  1. Import the created protobuf python script (this can confuse your linter).
  2. Create a protobuf message and use the .topic().write() function to log the message.

Example:

from mcap_logger.demo.sensor_data_pb2 import SensorData

sensor_message = SensorData(temperature=25, humidity=65)
logger.topic("/sensor_data").write(sensor_message)

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

mcap_logger-0.1.17.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

mcap_logger-0.1.17-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file mcap_logger-0.1.17.tar.gz.

File metadata

  • Download URL: mcap_logger-0.1.17.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mcap_logger-0.1.17.tar.gz
Algorithm Hash digest
SHA256 83f2d71a3a3079ad0d94d55db23235cc5c3b14ca0710c838eba1691523ababbc
MD5 b90acd5b86318e94033b51d2c2e124dd
BLAKE2b-256 b1b1cfdf9663b2f9bc93eef08443d72b53fee0671545bef8aaf532f049bfc90b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcap_logger-0.1.17.tar.gz:

Publisher: publishing.yml on 8-bit-hunters/mcap_logger

Attestations:

File details

Details for the file mcap_logger-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for mcap_logger-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 677909cf78634230d3dabd54ee781e3447f6c52fb154f0085546bee9434b4b41
MD5 543c204049ab39194da245dec4e78cbe
BLAKE2b-256 346d3ff40bbc2a619ee5ceb4d4512fd2ccd61938ecb85fcdf8f9c506748bebfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcap_logger-0.1.17-py3-none-any.whl:

Publisher: publishing.yml on 8-bit-hunters/mcap_logger

Attestations:

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