summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-14 20:28:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-14 20:28:36 (GMT)
commitd33344a030bececd68ce487445cd47a11ebdb3fd (patch)
tree3ac312566143f86c4b678863f44358af1127a8f7 /Lib/cgi.py
parentf64f9e9ec1f8f39dd8c889368ecaad0e198efcb6 (diff)
downloadcpython-d33344a030bececd68ce487445cd47a11ebdb3fd.zip
cpython-d33344a030bececd68ce487445cd47a11ebdb3fd.tar.gz
cpython-d33344a030bececd68ce487445cd47a11ebdb3fd.tar.bz2
Add cgi.closelog() function to close the log file
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index e198ed8..63771fc 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -76,7 +76,7 @@ def initlog(*allargs):
send an error message).
"""
- global logfp, log
+ global log, logfile, logfp
if logfile and not logfp:
try:
logfp = open(logfile, "a")
@@ -96,6 +96,15 @@ def nolog(*allargs):
"""Dummy function, assigned to log when logging is disabled."""
pass
+def closelog():
+ """Close the log file."""
+ global log, logfile, logfp
+ logfile = ''
+ if logfp:
+ logfp.close()
+ logfp = None
+ log = initlog
+
log = initlog # The current logging function