Skip to main content

Central loguru rotation with process-group SIGWINCH coordinated reopen

Project description

deepfos-loguru-corotate

基于 loguru集中日志轮转多进程协同 reopen:由单一进程(例如 Gunicorn master)按与 loguru FileSink 一致的规则执行 rename 轮转,再通过向同一进程组广播 SIGWINCH,使 worker / 子进程等在保留原有 SIGWINCH 处理的前提下链式执行 loguru 的 remove + configure,从而避免仍持有旧 inode 继续写归档前的文件。

功能概要

  • 集中轮转:轮询 should_rotate,到期则 rename 当前日志、重建目标文件、在 rotator 进程上执行本地 reopen,再 os.killpg(..., SIGWINCH) 通知同作业进程组。
  • SIGWINCH 链ensure_reopen_inited 安装处理器时保存原有处理函数;信号到达时调用原处理(如框架自带的 reopen),执行已登记的 loguru reopen。
  • fork 后状态:可在 worker post_worker_init 等场景调用 reset_reopen_state_after_fork,避免子进程继承不应共享的状态。
  • 压缩与保留:轮转生成的归档路径可在延迟后执行与 loguru 策略对齐的压缩与 retention(实现依赖 loguru 内部 API)。

安装

pip install deepfos-loguru-corotate

或从源码

pip install .

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

deepfos_loguru_corotate-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

File details

Details for the file deepfos_loguru_corotate-0.1.0.tar.gz.

File metadata

  • Download URL: deepfos_loguru_corotate-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.3

File hashes

Hashes for deepfos_loguru_corotate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fda2f53c7cd033f96620fa2c2d9e082957e20e09eccb3a7e256b752e1395cbd9
MD5 1c656411605a4d7aae931a007e81558a
BLAKE2b-256 9b5103ca20e11a87ec4a6c4bdd7bdbe1942e86443c9e8bc003a6ebeeb0685d33

See more details on using hashes here.

Supported by

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