Skip to main content

Log Queue

Project description

logq

Log Queue

implement logq.get()

import logq
def log_worker():
    while True:
        log_dict = logq.get()
        if not log_dict:
            break
        print(log_dict)
    
thread = threading.Thread(target=log_worker)
thread.start()
# ...
# thread.join()

logging

logq.info("start")
logq.info("finish")
log_dict = logq.get()
print(log_dict)

output:
{'timestamp': 1700000000.100001, 'process_id': 1234, 'thread_id': 1234567890, 'log_type': 'information', 'file_name': 'test.py', 'file_lineno': 2, 'text': 'start'}
{'timestamp': 1700000000.100002, 'process_id': 1234, 'thread_id': 1234567890, 'log_type': 'information', 'file_name': 'test.py', 'file_lineno': 2, 'text': 'start'}

flush logq.get()

def log_worker():
    while True:
        log_dict = logq.get()
        if not log_dict:
            break
        print(log_dict)

    while not logq.empty():
        log_dict = logq.get()
        print(log_dict)
        
    print("flush queue")

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

logqueue-0.0.0.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

logqueue-0.0.0-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page