Skip to content

Commit

Permalink
#1893: Add compile logs to error display windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Oct 30, 2023
1 parent f97ee46 commit f7bf2db
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
7 changes: 7 additions & 0 deletions error_display/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ main {
background-origin: border-box;
background-repeat: repeat;
color: rgb(201, 211, 207);
overflow-y: scroll;
/* Compile dialog uses FriendsListStatusLine:
Univers Std Condensed, weight=&00, tall=14
*/
}

details pre {
background: #d7d7d7;
color: black;
white-space: pre-wrap;
}
17 changes: 16 additions & 1 deletion error_display/templates/index.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@
<aside>{{ context }}</aside>
{% endif %}
</article>
<section id="render"></section>
<details{{ " open" if start_render_open else "" }}>
<summary>Chamber Preview</summary>
<section id="render"></section>
</details>
{% if log_vbsp %}
<details>
<summary>Geometry Compile Log</summary>
<pre>{{ log_vbsp }}</pre>
</details>
{% endif %}
{% if log_vrad %}
<details>
<summary>Lighting / Packing Compile Log</summary>
<pre>{{ log_vrad }}</pre>
</details>
{% endif %}
</main>
</body>
</html>
38 changes: 30 additions & 8 deletions src/error_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
__name__,
root_path=str(root_path),
)
# Compile logs.
LOGS = {'vbsp': '', 'vrad': ''}
config = Config()
config.bind = ["localhost:0"] # Use localhost, request any free port.
DELAY = 5 * 60 # After 5 minutes of no response, quit.
Expand All @@ -57,7 +59,16 @@ async def route_display_errors() -> str:
return await quart.render_template(
'index.html.jinja2',
error_text=current_error.message.translate_html(),
log_context=current_error.context,
context=current_error.context,
log_vbsp=LOGS['vbsp'],
log_vrad=LOGS['vrad'],
# Start the render visible if it has annotations.
start_render_open=bool(
current_error.points
or current_error.leakpoints
or current_error.lines
or current_error.barrier_hole
),
)


Expand Down Expand Up @@ -87,7 +98,7 @@ async def route_heartbeat() -> quart.ResponseReturnValue:
async def route_reload() -> quart.ResponseReturnValue:
"""Called by our VRAD, to make existing servers reload their data."""
update_deadline()
load_info()
await load_info()
resp = await app.make_response(('', http.HTTPStatus.NO_CONTENT))
resp.mimetype = 'text/plain'
return resp
Expand Down Expand Up @@ -135,12 +146,11 @@ def ngettext(self, single: str, plural: str, n: int, /) -> str:
return self.tokens.get(single.casefold(), single)


def load_info() -> None:
async def load_info() -> None:
"""Load the error info from disk."""
global current_error
try:
with open(DATA_LOC, 'rb') as f:
data = pickle.load(f)
data = pickle.loads(await trio.Path(DATA_LOC).read_bytes())
if not isinstance(data, ErrorInfo):
raise ValueError
except Exception:
Expand All @@ -151,8 +161,9 @@ def load_info() -> None:

translations: Dict[str, transtoken.GetText] = {}
try:
with open('bee2/pack_translation.bin', 'rb') as f:
package_data: List[Tuple[str, Dict[str, str]]] = pickle.load(f)
package_data: List[Tuple[str, Dict[str, str]]] = pickle.loads(
await trio.Path('bee2/pack_translation.bin').read_bytes()
)
except Exception:
LOGGER.exception('Failed to load package translations pickle!')
else:
Expand Down Expand Up @@ -186,7 +197,18 @@ async def timeout_func() -> None:
# Allow nursery to exit.
stop_sleeping.cancel()

load_info()
async def load_compiler(name: str) -> None:
"""Load a compiler log file."""
try:
LOGS[name] = await trio.Path(f'bee2/{name}.log').read_text('utf8')
except OSError:
LOGGER.warning('Could not read bee2/{}.log', name)

async with trio.open_nursery() as nursery:
nursery.start_soon(load_compiler, 'vbsp')
nursery.start_soon(load_compiler, 'vrad')
nursery.start_soon(load_info)

SERVER_INFO_FILE.unlink(missing_ok=True)
try:
async with trio.open_nursery() as nursery:
Expand Down

0 comments on commit f7bf2db

Please sign in to comment.