Giter VIP home page Giter VIP logo

socket-log-receiver's Introduction

License PyPI Version Package Status pyversion Status CircleCI Coverage Status Ruff

Socket Log Receiver

socket_log_receiver is a light-weight socket log receiving server. The server aggregates messages from multi-process applications via a socket and logs them to a single file. The service is used with Python's stdlib logging package, which by default does not support multi-process writes 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

These are equivalent.

By default, the receiver service starts listening on localhost:9020. These can be changed through CLI options; see the Help section below.

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.

Help

$ python -m socket_log_receiver -h
$ log_receiver -h

Undefined Signal

The receiver service's configuration is managed by resconfig. By default, the dynamic configuration update is trigged by SIGHUP. Some systems might not make this signal available, in which case you could use a different signal for the trigger using the command-line option, e.g.

$ log_receiver --reloader-signal SIGUSR2

Development

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

Running Tests

$ pip install -e .[test]
$ pytest

socket-log-receiver's People

Contributors

okomestudio avatar yogiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

yogiz

socket-log-receiver's Issues

Cannot give receiver port as cmd line argument

python3 -m socket_log_receiver --receiver-host localhost --receiver-port 9020

Running above gives error that the port is a string, and socket cannot be opened (requires int). Casting port to int solves the problem for me:

Receivers.py
84 #receiver = Receiver(con["host"], con["port"])
85 receiver = Receiver(con["host"], int(con["port"]))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.