TimedRotatingFileHandler using ctime instead of mtime to determine rollover times.
Project description
CTimedRotatingFileHandler
TimedRotatingFileHandler using ctime instead of mtime to determine rollover times.
This module provides a subclass CTimedRotatingFileHandler of logging.handlers.TimedRotatingFileHandler that 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'
log = 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)
log.info('This is an information.')
Development and building
Prerequesites
- Python 3.9 has to be installed with
pipand packages:virtualenvbuild
Setup development environment
After cloning the repo, you should create a virtual environment for all further development work.
This may be done by calling one of the included setup_venv scripts for your platform:
setup_venv.cmd: Windows batchsetup_venv.ps1: Windows Powershellsetup_venv.sh: Bash
This will
- create a new virtual environment in the directory
venvor update an existing one, - install all requirements from
requirements.txt.
You still have to activate the venv manually (or automatically by configuring it in your IDE).
Building the package
All buils settings are inside pyproject.toml.
You might want to change project.version before building (eg. add .dev1 to it), so you always know which one
you are dealing with.
To build the project, simply run this command from inside the project directory (the same directory that contains
pyproject.toml):
python -m build
This will create .whl and .tar.gz in the directory dist.
Project details
Release history Release notifications | RSS feed
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.1.2.tar.gz.
File metadata
- Download URL: ctimed_rotating_file_handler-0.1.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
697f7325c9d5312ccbfa5a5f4d14cc3b9f2ffc58a4e7fa24a0e13024f15f11ab
|
|
| MD5 |
1a7a772602097e704af89082d5258fee
|
|
| BLAKE2b-256 |
27a74f8d7b143e03ba4044849c2c2fb36cfecdb87f242d8bd14dc9e08f4b2126
|
File details
Details for the file ctimed_rotating_file_handler-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ctimed_rotating_file_handler-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
546c14d1397d66bd95ea3221ab073da6a95cfbee11bed07f9c496a4508972f89
|
|
| MD5 |
b97572dfa91366d191bb73add3a75f8b
|
|
| BLAKE2b-256 |
0461384806391964aa4e1a571299b3e2e0a11b36f07540fd7dc98df609647e0f
|