Set the file handle to log either or both warnings and diagnostics to. - setDiag and setWarn are True if the corresponding handle is to be set. - filename is None for no logging, '-' for stdout, or a pathname.
(setDiag, setWarn, filename)
| 57 | return f'{msg} ' |
| 58 | |
| 59 | def setLogFile(setDiag, setWarn, filename): |
| 60 | """Set the file handle to log either or both warnings and diagnostics to. |
| 61 | |
| 62 | - setDiag and setWarn are True if the corresponding handle is to be set. |
| 63 | - filename is None for no logging, '-' for stdout, or a pathname.""" |
| 64 | global diagFile, warnFile |
| 65 | |
| 66 | if filename is None: |
| 67 | return |
| 68 | |
| 69 | if filename == '-': |
| 70 | fp = sys.stdout |
| 71 | else: |
| 72 | fp = open(filename, 'w', encoding='utf-8') |
| 73 | |
| 74 | if setDiag: |
| 75 | diagFile = fp |
| 76 | if setWarn: |
| 77 | warnFile = fp |
| 78 | |
| 79 | def logDiag(*args, **kwargs): |
| 80 | file = kwargs.pop('file', diagFile) |
no outgoing calls
no test coverage detected