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

Uploaded Python 3

File details

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

File metadata

  • Download URL: watchlog_python-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 adaf38a33e0730e2e1a0584e367d0b611f6534a96ec5c08552e15eb44de4f1ac
MD5 7450e41f3a9e84b9e6bc3a988029895b
BLAKE2b-256 bb4a4a221066c73e27ade1e9a142b59578c390e13277b31badb6afeed731e0a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for watchlog_python-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2e2010fc69830ac061620500109c67fa7a6446396600addb042f740ce018fcfa
MD5 8736a6337cdb23ebfba5a6504640d30e
BLAKE2b-256 16dc8ba35d9e66b5ab0ad71c9cf863b902ca61f157595b676ad3378cd3defa92

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