Return a closure that reads the openshell log file(s). Since the sandbox uses a rolling file appender, logs are written to date-stamped files like ``/var/log/openshell.YYYY-MM-DD.log`` instead of a single ``/var/log/openshell.log``. This helper globs for all matching files so tests
()
| 175 | |
| 176 | |
| 177 | def _read_openshell_log(): |
| 178 | """Return a closure that reads the openshell log file(s). |
| 179 | |
| 180 | Since the sandbox uses a rolling file appender, logs are written to |
| 181 | date-stamped files like ``/var/log/openshell.YYYY-MM-DD.log`` instead |
| 182 | of a single ``/var/log/openshell.log``. This helper globs for all |
| 183 | matching files so tests work with both the legacy and rolling layouts. |
| 184 | """ |
| 185 | |
| 186 | def fn(): |
| 187 | import glob |
| 188 | |
| 189 | logs = [] |
| 190 | for path in sorted(glob.glob("/var/log/openshell*.log*")): |
| 191 | try: |
| 192 | with open(path) as f: |
| 193 | logs.append(f.read()) |
| 194 | except (FileNotFoundError, PermissionError): |
| 195 | pass |
| 196 | return "\n".join(logs) |
| 197 | |
| 198 | return fn |
| 199 | |
| 200 | |
| 201 | def _forward_proxy_with_server(): |
no outgoing calls
no test coverage detected