File: rotatinglog.py

package info (click to toggle)
twisted 12.0.0-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 9,720 kB
  • sloc: python: 78,364; ansic: 179; makefile: 113; sh: 34
file content (26 lines) | stat: -rw-r--r-- 490 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

# 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")