Skip to main content

A simple Python package for logging metrics.

Project description

watchlog-python

A Python client for watchlog server.

Installation

To install the package, use pip:

pip install watchlog-python

Usage

1. Import the Watchlog Class

First, import the Watchlog class from the watchlog package.

from watchlog import Watchlog

2. Create an Instance of Watchlog

Create an instance of the Watchlog class.

watchlog_instance = Watchlog()

3. Using Watchlog in Your Application

You can use the watchlog_instance to log different types of metrics. Below are examples of how to use various methods provided by the Watchlog class.

# Increment the specified metric by the given value (default is 1)
watchlog_instance.increment('page_views', 10)

# Decrement the specified metric by the given value (default is 1)
watchlog_instance.decrement('items_in_cart', 2)


# Set the specified metric to the given value
watchlog_instance.gauge('current_temperature', 22.5)

# Set the specified metric to a percentage value (0 to 100)
watchlog_instance.percentage('completion_rate', 85)


# Log a system byte metric
watchlog_instance.systembyte('memory_usage', 1024)

1. Example Usage in a Django View

# views.py
from django.http import HttpResponse
from watchlog import Watchlog

# Create an instance of Watchlog
watchlog_instance = Watchlog()

def some_view(request):
    # Increment the metric without blocking the main thread
    watchlog_instance.increment('view_hits')

    return HttpResponse("This is a view that increments a metric.")
    

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

watchlog_python-0.1.5.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file watchlog_python-0.1.5.tar.gz.

File metadata

  • Download URL: watchlog_python-0.1.5.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for watchlog_python-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9f3c3d0424095077b797d7dc54cb7fbf019aad637f1551dfbaeac88a79f4715a
MD5 a7eed81714d41ae6548ab0a02af68cd9
BLAKE2b-256 7d4ce61b21f97f70211ef1f5e3c435a6a0f20d68a933256b4f595952dcc14f3f

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