-- DBLog.mesa
-- created by Donahue, November 12, 1982 1:55 pm
-- last edited by Donahue, April 27, 1983 8:22 am

DIRECTORY
IO USING[ STREAM ],
Rope USING[ ROPE ];

DBLog: DEFINITIONS = {

OPEN Rope;

Log: TYPE = REF LogObj;

LogObj: TYPE =
MONITORED RECORD[ condition: CONDITION, locked: BOOLFALSE,
        name: ROPE, stream: IO.STREAMNIL ];

Initialize: PROC[fileName: ROPE] RETURNS[log: Log];

Flush: PROC[log: Log, reOpen: BOOLTRUE];

Length: PROC[log: Log] RETURNS[INT];

LogOp: PROC[log: Log, op: ROPE];

LogText: PROC[log: Log, prefix: ROPE, text: IO.STREAM] RETURNS[start: INT];

-- writes an entry in the log with the given text

Replay: PROC[ log: Log, from: INT,
     opProc: PROC[op: ROPE],
     textProc: PROC[prefix: ROPE, text: IO.STREAM] ];
-- perform all the log actions from this specified point
-- by calling the appropriate procedure for each entry

Copy: PROC[ oldLog: Log, newLog: Log, from: INT,
     filterText: PROC[prefix: ROPE, text: IO.STREAM, pos: INT] RETURNS[copy: BOOLEAN],
     filterOps: PROC[ op: ROPE] RETURNS[copy: BOOLEAN] ]
-- copy all of the text entries from the old log to the new log (beginning at from)
-- the filter procedures are applied to each entry
-- (pos gives the potential position of the prefix in the new log for text entries)
-- if the filter returns FALSE then the entry is not copied
}.