Skip to main content

Asynchronous log for python logging.

Project description

## asynclog
[![Build Status](]( [![Coverage Status](](

`asynclog` provide the asynchronous way for python logging. Leave the logging I/O(especially the network I/O when we want to logging to a network endpoint) to the asynchronous thread or asynchronous task provided by [celery]( .

#### Requirements

* Python 3.5+

#### Install

pip install asynclog

#### Usage

* Config from dict

log_cfg = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(asctime)s \n %(levelname)s \n %(message)s'
'handlers': {
'async_handler': {
'level': 'INFO',
'formatter': 'simple',
'class': 'asynclog.AsyncLogDispatcher',
'func': '[Dot_Path_To_Your_Func]',
'loggers': {
'asynclogger': {
'handlers': ['async_handler', ],
'level': 'DEBUG',
'propagate': False,

logger = logging.getLogger('asynclogger')'Test asynclog')

* Using thread

import logging
import time

from asynclog import AsyncLogDispatcher

def write_log(msg):
# Do write stuff, such as write log msg into network.
# ...

logger = logging.getLogger()
handler = AsyncLogDispatcher(write_log)
logger.addHandler(handler)'Test Log')

* Using Celery

from celery import shared_task

def write_task(msg):
# Write log in Network IO

celery_handler = AsyncLogDispatcher(write_task, use_thread=False, use_celery=True)
logger.addHandler(celery_handler)'Test Log')

#### Test

python3 -m unittest
Ran 6 tests in 0.007s


Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
asynclog-0.1.7.tar.gz (5.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page