Skip to main content

A lightweight logging library for Kybra on the Internet Computer (IC)

Project description

Kybra Simple Logging

Test PyPI version Python 3.10 License

A simple logging system for the Internet Computer built with Kybra. The library includes in-memory log storage capabilities, providing robust logging for all canister functions including asynchronous operations.

Features

  • Works seamlessly in both Internet Computer and non-IC environments
  • Avoids using Python's standard logging module (which has compatibility issues in the IC environment)
  • Named loggers with get_logger() function similar to Python's standard library
  • Support for level-based filtering (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • Global and per-logger log level configuration
  • Ability to enable/disable logging completely
  • Circular buffer to store logs in memory without exhausting memory

Installation

pip install kybra-simple-logging

Quick Start

from kybra_simple_logging import get_logger

# Create a logger
logger = get_logger("my_canister")

# Log messages at a specific level
logger.info("This is an info message")

# Set log level for a specific logger
logger.set_level(LogLevel.DEBUG)

# Use in-memory logging to retrieve logs
from kybra_simple_logging import get_logs, clear_logs, enable_memory_logging, disable_memory_logging

# Retrieve only ERROR logs
error_logs = get_logs(min_level="ERROR")

# Filter logs by logger name
component_logs = get_logs(logger_name="my_component")

Development

# Clone the repository
git clone https://github.com/smart-social-contracts/kybra-simple-logging.git
cd kybra-simple-logging

# Recommended setup
pyenv install 3.10.7
pyenv local 3.10.7
python -m venv venv
source venv/bin/activate

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
cd tests && ./run_test.sh

# Run linters
./run_linters.sh

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

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

kybra_simple_logging-0.1.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kybra_simple_logging-0.1.4-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file kybra_simple_logging-0.1.4.tar.gz.

File metadata

  • Download URL: kybra_simple_logging-0.1.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for kybra_simple_logging-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c8d2ca51d1041262c59cd814be6ca6bfe8ddca36e489a5d8074f334ee2040beb
MD5 1f8578b80d349fedfc1b2b075d4e685a
BLAKE2b-256 b8bce954df413ef5160437c0fd091ed77d7e917f478afce959a43b6ec187ccc9

See more details on using hashes here.

File details

Details for the file kybra_simple_logging-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for kybra_simple_logging-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ec07f034c67a600141db36384426e89c84eaa4a3b840c0f2f41de66797308445
MD5 4ec50442da5dc51ef437be7e90a50273
BLAKE2b-256 273900a7d82023ae49f0451127fa2b337b844a9ce93cbc6b84f76bdc8692c6ac

See more details on using hashes here.

Supported by

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