Message398692
The issue appears when the TimedRotatingHandler rolls over to a filename that already exists. Running your bash script, the handler correctly rolls over so you end up with the expected behaviour. This issue arises in the case that there is already a file with the target name, that file will be overwritten when the handler rolls over.
This can be seen clearly if you modify test.sh to contain
python3 log_44186.py foo
python3 log_44186.py bar
python3 log_44186.py baz
results are below:
$ python3 --version
Python 3.9.5
$ bash ./test.sh
10 14 51
TEST > [INFO] [2021-08-01 10:14:51] : foo 2021-08-01T10:14:51.521266
10 14 51
TEST > [INFO] [2021-08-01 10:14:51] : bar 2021-08-01T10:14:51.577802
10 14 51
TEST > [INFO] [2021-08-01 10:14:51] : baz 2021-08-01T10:14:51.634795
$ ls | grep .log
test.log
test.log.2021-07-31
$ cat test.log
baz 2021-08-01T10:14:51.634795
$ cat test.log.2021-07-31
bar 2021-08-01T10:14:51.577802
as you can see, the logs from foo have been overwritten.
A very similar result can be seen if you manually create a file and then run the test script.
$ python3 --version
Python 3.9.5
$ echo "logging test" > test.log.2021-07-31
$ python3 log_44186.py foo
10 33 25
TEST > [INFO] [2021-08-01 10:33:25] : foo 2021-08-01T10:33:25.003750
$ cat test.log
foo 2021-08-01T10:33:25.003750
$ cat test.log.2021-07-31
$
once again, you can see that the handler overwrote the target file (this time leaving it blank as there were no logs to write). |
|
Date |
User |
Action |
Args |
2021-08-01 09:35:10 | Harry-Lees | set | recipients:
+ Harry-Lees, vinay.sajip, aeg |
2021-08-01 09:35:10 | Harry-Lees | set | messageid: <1627810510.38.0.428156844552.issue44186@roundup.psfhosted.org> |
2021-08-01 09:35:10 | Harry-Lees | link | issue44186 messages |
2021-08-01 09:35:10 | Harry-Lees | create | |
|