(s)
| 23 | |
| 24 | |
| 25 | def log(s): |
| 26 | try: |
| 27 | sys.stdout.flush() |
| 28 | except (IOError, ValueError): # ValueError ~ I/O operation on closed file |
| 29 | pass |
| 30 | try: |
| 31 | # Put newline at end of string if line doesn't have one. |
| 32 | if not s.endswith("\n"): |
| 33 | s = s+"\n" |
| 34 | |
| 35 | prefix = logprefix |
| 36 | s = s.rstrip("\n") |
| 37 | for line in s.split("\n"): |
| 38 | sys.stderr.write(prefix + line + "\n") |
| 39 | prefix = " " |
| 40 | sys.stderr.flush() |
| 41 | except (IOError, ValueError): # ValueError ~ I/O operation on closed file |
| 42 | # this could happen if stderr gets forcibly disconnected, eg. because |
| 43 | # our tty closes. That sucks, but it's no reason to abort the program. |
| 44 | pass |
| 45 | |
| 46 | |
| 47 | def debug1(s): |
no test coverage detected