TimedRotatingFileHandler using ctime instead of mtime to determine rollover times.
Project description
CTimedRotatingFileHandler
TimedRotatingFileHandler for python logging, that uses ctime instead of mtime to determine rollover times.
This module provides CTimedRotatingFileHandler as a subclass of logging.handlers.TimedRotatingFileHandler.
It uses file creation time instead of file modification time to calculate the next rollover time.
It also contains a workaround for "file system tunneling" on Windows, which prevents new files from having new
creation times if they have already existed a short time ago.
To be able to do this, a new dependency to win32-setctime is introduced (only needed if running on Windows).
Usage Example
import logging
from ctimed_rotating_file_handler import CTimedRotatingFileHandler
logfile = 'path/to/logdir/MyName.log'
loglevel = logging.DEBUG
backupcount = 7
logformat = '%(asctime)s\t%(levelname)s\t%(name)s\t%(message)s'
logger = logging.getLogger()
formatter = logging.Formatter(fmt=logformat)
loghandler = CTimedRotatingFileHandler(logfile, when='midnight', interval=1, backupCount=backupcount)
loghandler.setFormatter(formatter)
logging.root.addHandler(loghandler)
logging.root.setLevel(loglevel)
logger.info('This is an information.')
Development and building
Prerequesites
This project uses uv for development, build and deploy, so uv has to be installed and
must be found on the system PATH.
All project settings can be found in pyproject.toml.
Setup development environment
After cloning the repo, run uv sync once to set up a venv with all dependencies in the directory .venv.
Building the package
You might want to change project.version in pyproject.toml before building (eg. add .dev1 to it), so you always
know which one you are dealing with.
To build the project, run this command from inside the project directory (the same directory that contains
pyproject.toml):
uv build
This will create .whl and .tar.gz in the directory dist.
Deployment
Before deploying to pypi.org or test.pypi.org, make sure the correct new version is entered in pyproject.toml.
Delete the dist folder and build the latest version so only this version is present (uv will try to upload all
versions it can find in the folder).
Test-Release on https://test.pypi.org
- Set the environment variable
UV_PUBLISH_TOKENto atest.pypi.org-token with privileges for this project. - Call
uv publishwith publish-url set to https://test.pypi.org/legacy/
Windows:
$env:UV_PUBLISH_TOKEN = "pypi-..."
uv publish --publish-url https://test.pypi.org/legacy/
Linux
export UV_PUBLISH_TOKEN="pypi-..."
uv publish --publish-url https://test.pypi.org/legacy/
Release on https://pypi.org
- Set the environment variable
UV_PUBLISH_TOKENto apypi.org-token with privileges for this project. - Call
uv publishwith no additional arguments
Windows:
$env:UV_PUBLISH_TOKEN = "pypi-..."
uv publish
Linux
export UV_PUBLISH_TOKEN="pypi-..."
uv publish
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctimed_rotating_file_handler-0.2.0.tar.gz.
File metadata
- Download URL: ctimed_rotating_file_handler-0.2.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f99852b45fdd98aeb6051c8aa4bcb5ffacd3afab1cdccbdefebed171dd451076
|
|
| MD5 |
025c429836013adbe3042ab542fbb79a
|
|
| BLAKE2b-256 |
e516efcbc8bd834379e191580d328db5fd65ed3734f051e10752e75c5a5982d0
|
File details
Details for the file ctimed_rotating_file_handler-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ctimed_rotating_file_handler-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b66ba514693014f01f7c753d0e129cbc7822ca92777702059a5c6a0bed306a1
|
|
| MD5 |
3acc4f5737e09cc9ca1a301007dcc807
|
|
| BLAKE2b-256 |
24e33758ea460250c2241fcdff0a3dc63dd13f5379f68396d25369c14f7b0945
|