recorder – Flight Data Recorder

CodeAIR: Flight Data Recorder

class codeair.recorder.FlightDataRecorder(filename=None, abort=<function _emergency_landing>)[source]

A class to record flight data and handle logging.

filename

The name of the log file. None for default.

Type

str

abort

The function to call on an unhandled exception.

Type

function

Initializes the FlightDataRecorder with a log file and abort function.

log(message)[source]

Logs a message to the file with a timestamp.

Parameters

message (str) – The message to log.

log_exception(e)[source]

Logs an exception with a traceback.

Parameters

e (Exception) – The exception to log.

print_report(check_connection=True)[source]

Prints the contents of the previous log file to the console.

Parameters

check_connection (bool) – If True, check if CodeSpace is connected before reporting.

set_file_mode(mode, do_flush=False)[source]

Sets the file mode for logging. Default is auto mode, which appends unless the log has been reported.

Parameters
  • mode (int) – The file mode (self.FMODE_OVERWRITE, self.FMODE_APPEND, self.FMODE_AUTO).

  • do_flush (bool) – Set True to aggressively flush every log write to disk.

write(data)[source]

Writes raw data to the log file.

Parameters

data (bytes) – The data to write.

Download Source