Skip to content

Commit 61302a8

Browse files
committedDec 18, 2023
implement debugging TeX daemon interfacing via DEBUG_TEX env var
1 parent 0a84aed commit 61302a8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎src/latexdsl/tex_daemon.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import std / [osproc, streams, strutils, strscans]
22

3+
from std / os import getEnv
4+
var DebugTexDaemon = getEnv("DEBUG_TEX", "false").parseBool
5+
36
type
47
TeXDaemon* = object
58
isReady*: bool
@@ -9,6 +12,8 @@ type
912

1013
proc write*(d: TeXDaemon, line: string) =
1114
if d.pid.running:
15+
if DebugTexDaemon:
16+
echo "Writing: ", line
1217
d.stdin.write(line & "\n")
1318
d.stdin.flush()
1419
else:
@@ -24,6 +29,8 @@ proc read*(d: TeXDaemon): string =
2429
c = d.stdout.readChar()
2530
data.add c
2631
result = data
32+
if DebugTexDaemon:
33+
echo "Read: ", result
2734
else:
2835
raise newException(IOError, "The TeXDaemon is not running anymore. Reading failed.")
2936

0 commit comments

Comments
 (0)