refactor LogWriter: remove friend class Logger and use the public interface

This commit is contained in:
Beat Küng 2016-05-06 13:18:38 +02:00 committed by Lorenz Meier
parent dde96dd4d7
commit 04f301619f
2 changed files with 13 additions and 4 deletions

View File

@ -13,7 +13,6 @@ namespace logger
class LogWriter
{
friend class Logger;
public:
LogWriter(size_t buffer_size);
~LogWriter();
@ -59,6 +58,16 @@ public:
return _total_written;
}
size_t get_buffer_size() const
{
return _buffer_size;
}
size_t get_buffer_fill_count() const
{
return _count;
}
private:
static void *run_helper(void *);

View File

@ -136,7 +136,7 @@ void Logger::status()
PX4_INFO("Wrote %4.2f MiB (avg %5.2f KiB/s)", (double)mebibytes, (double)(kibibytes / seconds));
PX4_INFO("Dropouts: %zu (max len: %.3f s), max used buffer: %zu / %zu B",
_write_dropouts, (double)_max_dropout_duration, _high_water, _writer._buffer_size);
_write_dropouts, (double)_max_dropout_duration, _high_water, _writer.get_buffer_size());
_high_water = 0;
_max_dropout_duration = 0.f;
}
@ -555,8 +555,8 @@ void Logger::run()
msg_id++;
}
if (!_dropout_start && _writer._count > _high_water) {
_high_water = _writer._count;
if (!_dropout_start && _writer.get_buffer_fill_count() > _high_water) {
_high_water = _writer.get_buffer_fill_count();
}
/* release the log buffer */