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.4.tar.gz (2.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: watchlog_python-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 53830d2d413606fd3a3fb701e12c92aed3b8c317b5c543a8f5e94055aa36bfa7
MD5 d9d0ceea9950200b912b1c6323d1adbd
BLAKE2b-256 e95da24eaf38a6703c2c48520f7359fa64b8fa5e0569ca16ca239f3f3ddebbd0

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