logappend -T <timestamp> -K <token> (-D <doctor-name> | -N <nurse-name>) (-A | -L) [-R <room-id>] -F <log>
logappend -B <file>
Appends data to the log at the specified timestamp using the authentication token. If the log does not exist, logappend
will create it. Otherwise it will append to the existing log.
If the data to be appended to the log is not consistent with the current state of the log, logappend
should exit with an error condition and leave the state of the log unchanged.
-T
timestamp Time the event is recorded.
-K
token Token used to authenticate the log. Once a log is created with a specific token, any subsequent appends or reads on that log must use the same token.
-D
name Name of doctor.
-N
name Name of nurse.
-A
Specify that the current event is an arrival; can be used with -D
, -N
, and -R
. This option can be used to signify the arrival of an doctor or nurse to the hospital, or to a specific room with -R
. If -R
is not provided, -A
indicates an arrival to the hospital as a whole.
-L
Specify that the current event is a departure, can be used with -D
, -N
, and -R
.This option can be used to signify the departure of an doctor or nurse from the hospital, or from a specific room with -R
. If -R
is not provided, -L
indicates a departure from the hospital as a whole.
-R
room-id Specifies the room ID for an event. Room IDs are positive integers with no spaces. Leading zeros in room IDs should be dropped, such that 003
, 03
, and 3
are all equivalent room IDs. The hospital is composed of multiple rooms. A complete list of the rooms of the hospital is not available and rooms will only be described when a doctor or nurse enters or leaves one. A room cannot be left by an doctor or nurse unless that doctor or nurse has previously entered that room. An doctor or nurse may only occupy one room at a time. If a room ID is not specified, the event is for the hospital as a whole.
-F
log The path to the file containing the event log. If the log does not exist, logappend
should create it. logappend
should add data to the log, preserving the history of the log such that queries from logread can be answered.
-B
file The path to a batch file of commands. The batch file's name may be specified with a string of alphanumeric characters (including underscores and periods), file contains one or more command lines, not including the logappend
command itself (just its options), separated by \n
(newlines). These commands should be processed by logappend
individually, in order. This allows logappend
to add data to the file without forking or re-invoking. Of course, option -B
cannot itself appear in these command lines. Commands specified in a batch file include the log name. If a single line in a batch file results in an error condition, print the appropriate error message for that line and continue processing the rest of the batch file. Here is an example (the last one).
After logappend
exits, the log specified by log
argument should be updated. The added information should be accessible by the logread
tool when the token provided to both programs is the same, and not available (e.g. by inspecting the file directly) otherwise.
If logappend
must exit with an error condition, or if the argument combination is incomplete or contradictory, the log should not be modified and logappend
should print "invalid" to stdout
and exit, returning 255.
logappend
should exit with an error condition.logappend
cannot authenticate the log with the token, then logappend
should should exit with an integrity violation.logappend
with an event at a time that is at or prior to the most recent event already recorded is an error.logappend
exiting with an error condition.logappend
exiting with an error condition.-B
is passed logappend
should return 0 as long as the batch file exists and valid arguments are given to the batch command.-B
is passed and the batch file does not exist, logappend
should exit with an error condition.Some examples of conditions that would result in printing "invalid" and doing nothing to the log:
-B
is used in a batch file.-D
and -N
or -A
and -L
.