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