Error, Information, Performance Logging
LogInfo:
TYPE =
RECORD[
logCode: ATOM←NIL,
logD1: LONG CARDINAL𡤀,
logD2: LONG CARDINAL𡤀
];
loggingGroups: CARDINAL;
LOG:
PROC[group:
CARDINAL𡤁, info: LogInfo←[]] =
TRUSTED
INLINE {
IF Basics.
BITAND[group, loggingGroups]#0
THEN {
WriteData[info]; Here[]; }; };
SLOG:
PROC[group:
CARDINAL𡤁] =
TRUSTED
INLINE {
IF Basics.
BITAND[group, Log.loggingGroups]#0
THEN {
Noop[]; Here[]; }; };
WriteData: PROC[info: LogInfo];
Noop: PROC;
Here: PROC;
DoLog: PROC[groups: CARDINAL];
Error reporting and management
Report finds an appropriate stream and prints a time-stamped version of remark. Clients can register procedures to interpret the WhereToReport atoms and obtain the appropriate stream for a given call, aided by the lead supplied in the Report call.
Problem is intended for reporting unexpected errors and conditions. It will raise the indicated signal, or an internal one by default, if the system is currently attended (there's an executive command.) In any case, it will report the remark argument. It will return automatically or if the operator proceeds from the signal, so the caller needs to do what is necessary to recover after calling Problem.
The other Problem... functions are for convenience in returning innocuous values from procedures.
The defaultIfNotFound parameter to the registration procedure indicates whether the message should be ignored (FALSE) or printed (TRUE) when the corresponding stream-finding procedure returns NIL.
WhereToReport: TYPE=ATOM;
ThHandle: TYPE = LONG CARDINAL -- Thrush.ThHandle --;
nullHandle: ThHandle = 0;
WhereProc: TYPE = PROC[fixedWhereData: REF, whereData: REF] RETURNS[s: IO.STREAM←NIL];
DNFProc: TYPE = PROC[fixedWhereData: REF, whereData: REF] RETURNS[default: BOOL];
RegisterWhereToReport:
PROC[
proc: WhereProc←NIL, where: WhereToReport, fixedWhereData: REF←NIL, defaultIfNotFound: DNFProc←NIL];
IF defaultIfNotFound=NIL, answer assumed TRUE
FindWhere: PROC[where: WhereToReport, whereData: REF] RETURNS [s: IO.STREAM←NIL];
Report: PROC[remark: ROPE, where: WhereToReport←NIL, whereData: REF ←NIL];
ReportFR:
PROC[remark:
ROPE, where: WhereToReport←
NIL, whereData:
REF ←
NIL,
a1, a2: IO.Value ← [rope[NIL]]];
Problem:
PROC[
remark: ROPE←NIL, where: WhereToReport←NIL, whereData: REF ←NIL];
ProblemFR:
PROC[
remark:
ROPE←
NIL, where: WhereToReport←
NIL, whereData:
REF ←
NIL,
a1, a2: IO.Value ← [rope[NIL]]];
ProblemBool:
PROC[remark:
ROPE←
NIL, where: WhereToReport←
NIL,
bool: BOOL←FALSE, whereData: REF←NIL]
RETURNS[sameBool: BOOL];
ProblemHandle:
PROC[remark:
ROPE←
NIL, where: WhereToReport←
NIL,
handle: ThHandle ← nullHandle, whereData: REF←NIL]
RETURNS[sameHandle: ThHandle];
Originally developed as part of ThMessageDBImpl
CLog: TYPE = REF CLogBody;
CLogBody:
TYPE =
RECORD [
logStream: IO.STREAM,
logReadPos: INT𡤀,
CommandProc:
PROC[CLog]
CommandProc should consume any command in the log, such that if it's the last
command, we're at end of file
];
MakeCLog:
PROC[fileName:
ROPE,
CommandProc:
PROC[CLog], new:
BOOL←
FALSE, keep:
CARDINAL𡤂]
RETURNS[cLog: CLog];
WriteCLog: PROC[cLog: CLog, entry: ROPE];
CloseCLog: PROC[cLog: CLog] RETURNS[nullCLog: CLog];
DoCLog:
PROC[cLog: CLog, entry:
ROPE];
Write it at end, then read it and do it, using CommandProc
RedoCLog:
PROC[cLog: CLog];
Typical thing to do after a MakeCLog, to replay an old one.
Dynamic "IsBound"; applies to procedures only.
GetBinding:
PROC[qualifiedName:
ROPE]
RETURNS [tv: AMTypes.
TV];
qualifiedName is either Interface.variable or Program.variable.
Returns NIL if the Interface, Program, or variable is undefined.
Assumes global context. I suppose there's a way to speed it up by looking for top level.
GetBindingToProc:
PROC[qualifiedProcName:
ROPE]
RETURNS [proc:
PROC
ANY
RETURNS
ANY];
qualifiedProcName is either Interface.Proc or Program.Proc.
Returns NIL if the Interface, Program, or Proc is undefined.
}.