mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Add cgi.closelog() function to close the log file
This commit is contained in:
parent
f64f9e9ec1
commit
d33344a030
3 changed files with 13 additions and 8 deletions
11
Lib/cgi.py
11
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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue