--------------------------------------------------------------------------
MODULE--------------------------------------------------------------------------; IMPORT Wr, Stdio, Process, Text; SMsg
PROCEDURE--------------------------------------------------------------------------Error (msg : TEXT) = BEGIN TRY IF beepFlag THEN Wr.PutChar(errorWr, '\007'); END; Wr.PutText(errorWr, " *** error: " & msg & "\n"); Wr.Flush(errorWr); EXCEPT ELSE END; END Error;
PROCEDURE--------------------------------------------------------------------------Fatal (msg : TEXT; exitCode : INTEGER := 1) = BEGIN TRY IF beepFlag THEN Wr.PutChar(fatalWr, '\007'); END; Wr.PutText(fatalWr, " ### fatal: " & msg & "\n"); Wr.Flush(fatalWr); EXCEPT ELSE END; Process.Exit(exitCode); END Fatal;
PROCEDURE--------------------------------------------------------------------------Warning (msg : TEXT) = BEGIN TRY IF beepFlag THEN Wr.PutChar(warningWr, '\007'); END; Wr.PutText(warningWr, " !!! warning: " & msg & "\n"); Wr.Flush(warningWr); EXCEPT ELSE END; END Warning;
PROCEDURE--------------------------------------------------------------------------Debug (msg : TEXT) = BEGIN TRY Wr.PutText(debugWr, " === debug: " & msg & "\n"); Wr.Flush(debugWr); EXCEPT ELSE END; END Debug;
PROCEDURE--------------------------------------------------------------------------Error2 (proc, msg : TEXT) = BEGIN TRY IF beepFlag THEN Wr.PutChar(errorWr, '\007'); END; Wr.PutText(errorWr, " *** error in " & proc & ": " & msg & "\n"); Wr.Flush(errorWr); EXCEPT ELSE END; END Error2;
PROCEDURE--------------------------------------------------------------------------Fatal2 (proc, msg : TEXT; exitCode : INTEGER := 1) = BEGIN TRY IF beepFlag THEN Wr.PutChar(fatalWr, '\007'); END; Wr.PutText(fatalWr, " ### fatal in " & proc & ": " & msg & "\n"); Wr.Flush(fatalWr); EXCEPT ELSE END; Process.Exit(exitCode); END Fatal2;
PROCEDURE--------------------------------------------------------------------------Warning2 (proc, msg : TEXT) = BEGIN TRY IF beepFlag THEN Wr.PutChar(warningWr, '\007'); END; Wr.PutText(warningWr, " !!! warning in " & proc & ": " & msg & "\n"); Wr.Flush(warningWr); EXCEPT ELSE END; END Warning2;
PROCEDURE--------------------------------------------------------------------------Debug2 (proc, msg : TEXT) = BEGIN TRY Wr.PutText(debugWr, " === debug in " & proc & ": " & msg & "\n"); Wr.Flush(debugWr); EXCEPT ELSE END; END Debug2;
PROCEDURE--------------------------------------------------------------------------V (msg : TEXT; unconditionalNewLine := TRUE) = BEGIN IF vFlag THEN TRY IF unconditionalNewLine OR NOT Text.Empty(msg) THEN Wr.PutText(vWr, msg & "\n"); Wr.Flush(vWr); END; EXCEPT ELSE END; END; END V;
PROCEDURE--------------------------------------------------------------------------V2 (proc, msg : TEXT; unconditionalNewLine := TRUE) = BEGIN IF vFlag THEN TRY IF unconditionalNewLine OR NOT Text.Empty(msg) THEN Wr.PutText(vWr, proc & ": " & msg & "\n"); Wr.Flush(vWr); END; EXCEPT ELSE END; END; END V2;
PROCEDURE--------------------------------------------------------------------------T (msg : TEXT; unconditionalNewLine := TRUE) = BEGIN IF tFlag THEN TRY IF unconditionalNewLine OR NOT Text.Empty(msg) THEN Wr.PutText(tWr, msg & "\n"); Wr.Flush(tWr); END; EXCEPT ELSE END; END; END T;
PROCEDURE--------------------------------------------------------------------------T2 (proc, msg : TEXT; unconditionalNewLine := TRUE) = BEGIN IF tFlag THEN TRY IF unconditionalNewLine OR NOT Text.Empty(msg) THEN Wr.PutText(tWr, proc & ": " & msg & "\n"); Wr.Flush(tWr); END; EXCEPT ELSE END; END; END T2;
PROCEDURE--------------------------------------------------------------------------D (msg : TEXT; unconditionalNewLine := TRUE) = BEGIN IF dFlag THEN TRY IF unconditionalNewLine OR NOT Text.Empty(msg) THEN Wr.PutText(dWr, msg & "\n"); Wr.Flush(dWr); END; EXCEPT ELSE END; END; END D;
PROCEDURE--------------------------------------------------------------------------D2 (proc, msg : TEXT; unconditionalNewLine := TRUE) = BEGIN IF dFlag THEN TRY IF unconditionalNewLine OR NOT Text.Empty(msg) THEN Wr.PutText(dWr, proc & ": " & msg & "\n"); Wr.Flush(dWr); END; EXCEPT ELSE END; END; END D2;
BEGIN errorWr := Stdio.stderr; fatalWr := Stdio.stderr; debugWr := Stdio.stderr; warningWr := Stdio.stderr; vWr := Stdio.stdout; dWr := Stdio.stdout; tWr := Stdio.stdout; vFlag := FALSE; dFlag := FALSE; tFlag := FALSE; beepFlag := FALSE; END SMsg.