Skip to main content

A light-weight socket log receiver

Project description

pyversion Status CircleCI Coverage Status Code style: black

Socket Log Receiver

socket_log_receiver is a light-weight socket log receiver. It runs as a server and aggregates messages from multi-process application via socket and logs to a single file. Python's logging package does not support logging to a single file from multiple processes. By pointing SocketHandler to socket_log_receiver, the multi-process application can log to a single file.

Installation

$ pip install socket-log-receiver

Basic Usage

The receiver service should be run as a service.

$ python -m socket_log_receiver  # as a module
$ log_receiver                   # as a command-line program

In the application, use SocketHandler to send logs to the receiver service.

from logging.handlers import SocketHandler

handler = SocketHandler('localhost', 9020)  # handler to send logs to localhost:9020
logging.root.addHandler(handler)            # add the socket handler to the root logger

This way, the root logger sends logging messages to the receiver service.

Development

$ pip install -e .[dev]
$ pre-commit install

Running Tests

$ python setup.py tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for socket-log-receiver, version 20.4.1a0
Filename, size File type Python version Upload date Hashes
Filename, size socket_log_receiver-20.4.1a0-py3-none-any.whl (5.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size socket-log-receiver-20.4.1a0.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page