| 1 |
# Copyright (c) Twisted Matrix Laboratories. |
| 2 |
# See LICENSE for details. |
| 3 |
|
| 4 |
|
| 5 |
""" |
| 6 |
An example of using the rotating log. |
| 7 |
""" |
| 8 |
|
| 9 |
from twisted.python import log, logfile |
| 10 |
|
| 11 |
# rotate every 100 bytes |
| 12 |
f = logfile.LogFile("test.log", "/tmp", rotateLength=100) |
| 13 |
|
| 14 |
# setup logging to use our new logfile |
| 15 |
log.startLogging(f) |
| 16 |
|
| 17 |
# print a few message |
| 18 |
for i in range(10): |
| 19 |
log.msg(f"this is a test of the logfile: {i}") |
| 20 |
|
| 21 |
# rotate the logfile manually |
| 22 |
f.rotate() |
| 23 |
|
| 24 |
log.msg("goodbye") |