| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f64f9e9 commit d33344a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ def initlog(*allargs): | |||
| 76 | 76 | send an error message). | |
| 77 | 77 | ||
| 78 | 78 | """ | |
| 79 | - global logfp, log | ||
| 79 | + global log, logfile, logfp | ||
| 80 | 80 | if logfile and not logfp: | |
| 81 | 81 | try: | |
| 82 | 82 | logfp = open(logfile, "a") | |
@@ -96,6 +96,15 @@ def nolog(*allargs): | |||
| 96 | 96 | """Dummy function, assigned to log when logging is disabled.""" | |
| 97 | 97 | pass | |
| 98 | 98 | ||
| 99 | + def closelog(): | ||
| 100 | + """Close the log file.""" | ||
| 101 | + global log, logfile, logfp | ||
| 102 | + logfile = '' | ||
| 103 | + if logfp: | ||
| 104 | + logfp.close() | ||
| 105 | + logfp = None | ||
| 106 | + log = initlog | ||
| 107 | + | ||
| 99 | 108 | log = initlog # The current logging function | |
| 100 | 109 | ||
| 101 | 110 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,13 +155,7 @@ def test_log(self): | |||
| 155 | 155 | cgi.logfp = None | |
| 156 | 156 | cgi.logfile = "/dev/null" | |
| 157 | 157 | cgi.initlog("%s", "Testing log 3") | |
| 158 | - def log_cleanup(): | ||
| 159 | - """Restore the global state of the log vars.""" | ||
| 160 | - cgi.logfile = '' | ||
| 161 | - cgi.logfp.close() | ||
| 162 | - cgi.logfp = None | ||
| 163 | - cgi.log = cgi.initlog | ||
| 164 | - self.addCleanup(log_cleanup) | ||
| 158 | + self.addCleanup(cgi.closelog) | ||
| 165 | 159 | cgi.log("Testing log 4") | |
| 166 | 160 | ||
| 167 | 161 | def test_fieldstorage_readline(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,6 +225,8 @@ Core and Builtins | |||
| 225 | 225 | Library | |
| 226 | 226 | ------- | |
| 227 | 227 | ||
| 228 | + - Add cgi.closelog() function to close the log file. | ||
| 229 | + | ||
| 228 | 230 | - Issue #12502: asyncore: fix polling loop with AF_UNIX sockets. | |
| 229 | 231 | ||
| 230 | 232 | - Issue #4376: ctypes now supports nested structures in a endian different than | |
| Back | FazBrowse Home | New Git URL |
0 commit comments