Skip to main content

A simple Python package for logging metrics.

Project description

django-watchlog

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

Uploaded Source

Built Distribution

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

watchlog_python-0.1.1-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: watchlog_python-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b5cb9fcfa3467a4ce943136412e9f0e536352f882251227b1f23b1c13ad3190c
MD5 5888e8dbae826a1cf95b9e165bb6f525
BLAKE2b-256 35bed6339b45f013ec0e40086330edf6723f89f880f367eed702732e1070dfd7

See more details on using hashes here.

File details

Details for the file watchlog_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for watchlog_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 be2865d0db92d8e2ff14e28814ae0a9000a7348628bc84a9dd84cd2c54948d28
MD5 3dd7c84fe6e22d7e2c62ce9e638c339b
BLAKE2b-256 3ffc755fc83d7e719c22f5e6b9a86abcaa176d1d647724db463b42e988dc4633

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