Git Product home page Git Product logo

logserver's Introduction

logserver

https://travis-ci.org/mivade/logserver.svg?branch=master

A reusable, dependency-free log server for Python.

Features

  • No dependencies outside of the Python standard library
  • Uses UDP for fast transmission of logs
  • Server for handling aggregated logs can run independently, as a thread, or as as a subprocess
  • Includes a convenience function for pre-configuring loggers to work with the server and formatting messages on STDOUT
  • Includes a handler for logging to SQLite
  • MIT license

Usage with the multiprocessing module

Example usage:

from multiprocessing import Process
from logging import StreamHandler
from logserver import LogServerProcess

handlers = [StreamHandler()]
server = LogServerProcess(handlers)
server.start()
server.ready.wait()

# do other stuff...

Running as a standalone server

logserver can be executed as a script to run as a standalone process to consume logs from clients:

$ python -m logserver -f db.sqlite

Development

Testing requires pytest and pytest-cov. To run tests:

$ pip install -r test-requirements.txt
$ pytest

logserver's People

Contributors

mivade avatar

Watchers

 avatar  avatar

logserver's Issues

Process-based server doesn't work on Windows

I get the following traceback (similar traceback when trying to run the tests on Windows):

Traceback (most recent call last):
  File "C:/Users/OdinUser/src/SYS3/ramulator_main.py", line 23, in <module>
    log_server.start()
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\multiprocessing\process.py", line 130, in start
    self._popen = Popen(self)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\multiprocessing\forking.py", line 277, in __init__
    dump(process_obj, to_child, HIGHEST_PROTOCOL)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\multiprocessing\forking.py", line 199, in dump
    ForkingPickler(file, protocol).dump(obj)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 224, in dump
    self.save(obj)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 425, in save_reduce
    save(state)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 687, in _batch_setitems
    save(v)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 606, in save_list
    self._batch_appends(iter(obj))
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 642, in _batch_appends
    save(tmp[0])
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 425, in save_reduce
    save(state)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 687, in _batch_setitems
    save(v)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 425, in save_reduce
    save(state)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 687, in _batch_setitems
    save(v)
  File "C:\Users\OdinUser\Miniconda3\envs\ram\lib\pickle.py", line 306, in save
    rv = reduce(self.proto)
TypeError: can't pickle thread.lock objects

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.