Skip to content

Instantly share code, notes, and snippets.

@kaajavi
Created September 23, 2015 01:11
Show Gist options
  • Save kaajavi/53f85a7d7b97d20ee323 to your computer and use it in GitHub Desktop.
Save kaajavi/53f85a7d7b97d20ee323 to your computer and use it in GitHub Desktop.
Rotated file log twisted
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
An example of using the rotating log.
"""
from twisted.python import log
from twisted.python import logfile
# rotate every 100 bytes
f = logfile.LogFile("test.log", "/tmp", rotateLength=100)
# setup logging to use our new logfile
log.startLogging(f)
# print a few message
for i in range(10):
log.msg("this is a test of the logfile: %s" % i)
# rotate the logfile manually
f.rotate()
log.msg("goodbye")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment