日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python多线程logger_python多线程logger_Dblogger:一个Python语言实现支持多进程和多线程日志打印高效Python日志库......

發布時間:2023/12/10 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python多线程logger_python多线程logger_Dblogger:一个Python语言实现支持多进程和多线程日志打印高效Python日志库...... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

日期作者版本備注2020-12-7dingbinv1.0

Dblogger: a powerful Python library supporting multi process and multi thread printing logs

Dblogger project implements a both multi-threads-safe and multi-process-safe logger library named dblogger in python language. It works well and has stable function and powerful performance,especially in multithreaded or multiprocessed Python programs.

Main interfaces of dblogger are implemented in file: smartlogger/utils.dblogger.py .

dblogger configuration file is: smartlogger/conf/logger.conf.

The dblogger configuration file has the following format:[loggers]

keys=root,SafeLogger

[handlers]

keys=consoleHandler,fileHandler,rotatingFileHandler,timedRotatingFileHandler,truncateTimedRotatingFileHandler

[formatters]

keys=fmt0

[logger_root]

level=INFO

handlers=consoleHandler

[logger_SafeLogger]

level=INFO

#handlers=consoleHandler,truncateTimedRotatingFileHandler

handlers=truncateTimedRotatingFileHandler

qualname=SafeLogger

propagate=0

[handler_consoleHandler]

class=StreamHandler

args=(sys.stdout,)

level=INFO

formatter=fmt0

[handler_fileHandler]

class=FileHandler

args=("logs/app.log", "a")

level=INFO

formatter=fmt0

[handler_rotatingFileHandler]

class=handlers.RotatingFileHandler

args=("logs/app.log", 'a',100*1024*1024, 100)

level=INFO

formatter=fmt0

[handler_timedRotatingFileHandler]

class=handlers.TimedRotatingFileHandler

args=("logs/app.log", 'm', 1, 3600)

level=INFO

formatter=fmt0

[handler_truncateTimedRotatingFileHandler]

class=smartlogger.utils.logutils.truncate_timed_rotating_filehandler.TruncateTimedRotatingFileHandler

args=("logs/app.log", 'm', 1, 3600)

level=INFO

formatter=fmt0

[formatter_fmt0]

format=[%(asctime)s] [%(msecs)d,process(%(process)d),thread(%(thread)d),%(filename)s:%(lineno)d -- %(funcName)s() %(levelname)s] [%(message)s]

datefmt=%Y-%m-%d %H:%M:%S

TruncateTimedRotatingFileHandler was so important that it implements the following features: every few minutes or hours, it generates the log file name with a specific meaning, and then outputs the log content to the log file with the corresponding name. It was a truncated time rotating file handler and it's so useful.

You can run dblogger demo examples like this:python -m smartlogger.loggerdemo.simpleloggerdemo

python -m smartlogger.utils.logutils.dbloggerdemo

Then you will see the rotating log files generated under directory: smartlogger/logs after run above demo commands. And the log file names may be like: app.log and app.log.2020-11-08_01-01 and so on.

See GitHub address: https://github.com/apollo008/dblogger for source code and details.

總結

以上是生活随笔為你收集整理的python多线程logger_python多线程logger_Dblogger:一个Python语言实现支持多进程和多线程日志打印高效Python日志库......的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。