Logging Commands

Logging commands work from the environment handle to control the use of the log files.  Log files are opened when the environment is opened and closed when the environment is closed.  In all of the commands in the logging subsystem that take or return a log sequence number, it is of the form:
{fileid offset}
where the fileid is an identifier of the log file, as returned from the log_get call.

> <env> log_archive [-arch_abs] [-arch_data] [-arch_log]

This command returns  a list of log files that are no longer in use.  It is a direct call to the log_archive function. The arguments are:



> <env> log_compare lsn1 lsn2

This command compares two log sequence numbers, given as lsn1 and lsn2.  It is a direct call to the log_compare function.  It will return a -1, 0, 1 to indicate if lsn1 is less than, equal to or greater than lsn2 respectively.



> <env> log_file lsn

This command returns  the file name associated with the given lsn.  It is a direct call to the log_file function.



> <env> log_flush [lsn]

This command  flushes the log up to the specified lsn or flushes all records if none is given  It is a direct call to the log_flush function.  It returns either a 0 (for success), a DB error message or it throws a Tcl error with a system message.



> <env> log_get [-checkpoint] [-current] [-first] [-last] [-next] [-prev] [-set lsn]

This command retrieves a record from the log according to the lsn given and returns it and the data.  It is a direct call to the log_get function.  It is a way of implementing a manner of log iteration similar to cursors.   The information we return is similar to database information.  We return a list where the first item is the LSN (which is a list itself) and the second item is the data.  So it looks like, fully expanded, {{fileid offset} data}.  In the case where DB_NOTFOUND is returned, we return an empty list {}.  All other errors return a Tcl error.  The arguments are:



> <env> log_put [-checkpoint] [-flush] record

This command stores a record into the log and returns the LSN of the log record.  It is a direct call to the log_put function.  It returns either an LSN or it throws a Tcl error with a system message.  The arguments are:



> <env> log_stat

This command returns  the statistics associated with the logging subsystem.  It is a direct call to the log_stat function.  It returns a list of name/value pairs of the DB_LOG_STAT structure.