Skip to main content

多进程日志切换处理器

  • 一个安全可靠高效的进程间日志处理器 A safe, reliable and efficient inter process log processor fix bugs 修复上一版的bug

  • speed about 7100 lines/s 0.8M/s (10 processes) 7100行/s 0.8M/s 测试环境 虚拟机(virtual machine)

  • CentOS7 64

  • python3.7

  • 机械硬盘 hard disk

  • 添加测试用例

  • 新增参数 need_zip 是否需要日志压缩 布尔值 (需要以命名关键字参数传入)

  • 新增参数 compresslevel 日志压缩的gzip等级 默认为9 (需要以命名关键字参数传入)

  • v 0.5 修复上一版(0.4)的bug

  • import logging
    
    from multiprocessing import Process
    from logging import Formatter
    
    from multiprocess_logger import MultiprocessingHandler
    
    handler = MultiprocessingHandler(filename='./ppp.log',
                                     maxBytes=1024 * 1024, backupCount=10, need_zip=True, compresslevel=9)
    fmt = Formatter(fmt='%(asctime)s - %(process)d - %(name)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')
    handler.setFormatter(fmt=fmt)
    logger = logging.getLogger('SHIT')
    logger.addHandler(handler)
    logger.setLevel(logging.INFO)
    
    logging.basicConfig(level=logging.ERROR,
                        format='%(asctime)s - %(process)d - %(name)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')
    
    
    def write_log():
        while True:
            logger.info('Hello World!------------Hello World!')
    
    
    if __name__ == '__main__':
        # write_log()
        p_list = []
        for i in range(6):
            p_list.append(Process(target=write_log))
    
        for i in p_list:
            i.start()
    
    
    

Release files for multiprocess-logger 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multiprocess-logger 0.5
File Size Uploaded
multiprocess_logger-0.5.tar.gz 3.5 kB Details

Release files / multiprocess_logger-0.5.tar.gz

Download URL multiprocess_logger-0.5.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ae0e23d8b6fc0f86ef1d3e73562ca594fb02ea74ade7e6a86fee25fde225dcbf
BLAKE2b-256 checksum
How to use checksums
503a152de87fc5273bc406b0073000119ddcaff6ad86dc59e13d766ca81caf67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.5 This release

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page