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.2.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.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: watchlog_python-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 87c2d10dcd918644daaeb30cb93eb7956af4391a0304c78ef26ef3669103661a
MD5 04990c568b9bb262834e2a7e141b59d4
BLAKE2b-256 c396afaf971e1e2201ff7bb9354f890d0f218a025fb26726e58887b9fc1effd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for watchlog_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ad82fdf7298fcd4444b53d4518d36da2b31df684cecc74cdf43e28464f06dab
MD5 d5897fe1e209cad1607b6fff5da85bf5
BLAKE2b-256 31af328da9bfc52134fd30f7891cf6aef0c3853dbb573d21d43a9ab753942f8e

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