From d33344a030bececd68ce487445cd47a11ebdb3fd Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 14 Jul 2011 22:28:36 +0200 Subject: Add cgi.closelog() function to close the log file --- Lib/cgi.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Lib/cgi.py') diff --git a/Lib/cgi.py b/Lib/cgi.py index e198ed8653..63771fc9c6 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 -- cgit v1.2.1