PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Writes logging data to a file. More...
#include <log_writer_file.h>
Classes | |
class | LogFileBuffer |
Public Member Functions | |
LogWriterFile (size_t buffer_size) | |
~LogWriterFile () | |
bool | init () |
int | thread_start () |
start the thread More... | |
void | thread_stop () |
void | start_log (LogType type, const char *filename) |
void | stop_log (LogType type) |
bool | is_started (LogType type) const |
int | write_message (LogType type, void *ptr, size_t size, uint64_t dropout_start=0) |
void | lock () |
void | unlock () |
void | notify () |
size_t | get_total_written (LogType type) const |
size_t | get_buffer_size (LogType type) const |
size_t | get_buffer_fill_count (LogType type) const |
void | set_need_reliable_transfer (bool need_reliable) |
bool | need_reliable_transfer () const |
pthread_t | thread_id () const |
Private Member Functions | |
void | run () |
int | hardfault_store_filename (const char *log_file) |
permanently store the ulog file name for the hardfault crash handler, so that it can append crash logs to the last ulog file. More... | |
int | write (LogType type, void *ptr, size_t size, uint64_t dropout_start) |
write w/o waiting/blocking More... | |
Static Private Member Functions | |
static void * | run_helper (void *) |
Private Attributes | |
LogFileBuffer | _buffers [(int) LogType::Count] |
bool | _exit_thread = false |
bool | _need_reliable_transfer = false |
pthread_mutex_t | _mtx |
pthread_cond_t | _cv |
pthread_t | _thread = 0 |
Static Private Attributes | |
static constexpr size_t | _min_write_chunk = 4096 |
Writes logging data to a file.
Definition at line 64 of file log_writer_file.h.
px4::logger::LogWriterFile::LogWriterFile | ( | size_t | buffer_size | ) |
Definition at line 56 of file log_writer_file.cpp.
References _cv, _min_write_chunk, _mtx, math::max(), PC_ELAPSED, and perf_alloc.
px4::logger::LogWriterFile::~LogWriterFile | ( | ) |
Definition at line 78 of file log_writer_file.cpp.
|
inline |
Definition at line 114 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::get_buffer_fill_count_file().
|
inline |
Definition at line 109 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::get_buffer_size_file().
|
inline |
Definition at line 104 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::get_total_written_file().
|
private |
permanently store the ulog file name for the hardfault crash handler, so that it can append crash logs to the last ulog file.
log_file | path to the log file |
Definition at line 116 of file log_writer_file.cpp.
References fd, HARDFAULT_MAX_ULOG_FILE_LEN, HARDFAULT_ULOG_PATH, and write().
Referenced by start_log().
bool px4::logger::LogWriterFile::init | ( | ) |
Definition at line 73 of file log_writer_file.cpp.
Referenced by px4::logger::LogWriter::init().
|
inline |
Definition at line 84 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::is_started(), and write().
|
inline |
Definition at line 89 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::lock(), start_log(), and write_message().
|
inline |
Definition at line 124 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::need_reliable_transfer().
|
inline |
Definition at line 99 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::notify(), start_log(), stop_log(), thread_stop(), and write_message().
|
private |
Definition at line 197 of file log_writer_file.cpp.
References _buffers, _cv, _exit_thread, _min_write_chunk, _mtx, px4::logger::LogWriterFile::LogFileBuffer::_should_run, px4::logger::LogWriterFile::LogFileBuffer::close_file(), px4::logger::Count, fd, px4::logger::LogWriterFile::LogFileBuffer::fsync(), px4::logger::LogWriterFile::LogFileBuffer::get_read_ptr(), hrt_absolute_time(), hrt_abstime, px4::logger::LogWriterFile::LogFileBuffer::mark_read(), start(), and px4::logger::LogWriterFile::LogFileBuffer::write_to_file().
Referenced by run_helper().
|
staticprivate |
Definition at line 189 of file log_writer_file.cpp.
References run().
Referenced by thread_start().
|
inline |
Definition at line 119 of file log_writer_file.h.
Referenced by px4::logger::LogWriter::set_need_reliable_transfer().
void px4::logger::LogWriterFile::start_log | ( | LogType | type, |
const char * | filename | ||
) |
Definition at line 84 of file log_writer_file.cpp.
References _buffers, fd, px4::logger::Full, hardfault_store_filename(), lock(), px4::logger::log_type_str(), notify(), system_usleep, and unlock().
Referenced by px4::logger::LogWriter::start_log_file().
void px4::logger::LogWriterFile::stop_log | ( | LogType | type | ) |
Definition at line 148 of file log_writer_file.cpp.
References _buffers, and notify().
Referenced by px4::logger::LogWriter::stop_log_file().
|
inline |
Definition at line 129 of file log_writer_file.h.
References write().
Referenced by px4::logger::LogWriter::thread_id_file().
int px4::logger::LogWriterFile::thread_start | ( | ) |
start the thread
Definition at line 154 of file log_writer_file.cpp.
References _thread, and run_helper().
Referenced by px4::logger::LogWriter::init().
void px4::logger::LogWriterFile::thread_stop | ( | ) |
Definition at line 172 of file log_writer_file.cpp.
References _buffers, _exit_thread, px4::logger::LogWriterFile::LogFileBuffer::_should_run, _thread, and notify().
Referenced by px4::logger::LogWriter::thread_stop().
|
inline |
Definition at line 94 of file log_writer_file.h.
Referenced by start_log(), px4::logger::LogWriter::unlock(), and write_message().
|
private |
write w/o waiting/blocking
Definition at line 345 of file log_writer_file.cpp.
References _buffers, ulog_message_dropout_s::duration, hrt_elapsed_time(), and is_started().
Referenced by hardfault_store_filename(), write_message(), and px4::logger::LogWriterFile::LogFileBuffer::write_to_file().
int px4::logger::LogWriterFile::write_message | ( | LogType | type, |
void * | ptr, | ||
size_t | size, | ||
uint64_t | dropout_start = 0 |
||
) |
Definition at line 307 of file log_writer_file.cpp.
References _buffers, _need_reliable_transfer, lock(), math::min(), notify(), unlock(), and write().
Referenced by px4::logger::LogWriter::write_message().
|
private |
Definition at line 197 of file log_writer_file.h.
Referenced by run(), start_log(), stop_log(), thread_stop(), write(), and write_message().
|
private |
Definition at line 202 of file log_writer_file.h.
Referenced by LogWriterFile(), run(), and ~LogWriterFile().
|
private |
Definition at line 199 of file log_writer_file.h.
Referenced by run(), and thread_stop().
|
staticprivate |
Definition at line 150 of file log_writer_file.h.
Referenced by LogWriterFile(), and run().
|
private |
Definition at line 201 of file log_writer_file.h.
Referenced by LogWriterFile(), run(), and ~LogWriterFile().
|
private |
Definition at line 200 of file log_writer_file.h.
Referenced by write_message().
|
private |
Definition at line 203 of file log_writer_file.h.
Referenced by thread_start(), and thread_stop().