diff --git a/libraries/AP_Logger/AP_Logger_File.cpp b/libraries/AP_Logger/AP_Logger_File.cpp index 5ae398c448..4cb436d957 100644 --- a/libraries/AP_Logger/AP_Logger_File.cpp +++ b/libraries/AP_Logger/AP_Logger_File.cpp @@ -83,10 +83,14 @@ void AP_Logger_File::Init() } bufsize *= 1024; + const uint32_t desired_bufsize = bufsize; + // If we can't allocate the full size, try to reduce it until we can allocate it while (!_writebuf.set_size(bufsize) && bufsize >= _writebuf_chunk) { - hal.console->printf("AP_Logger_File: Couldn't set buffer size to=%u\n", (unsigned)bufsize); - bufsize >>= 1; + bufsize *= 0.9; + } + if (bufsize >= _writebuf_chunk && bufsize != desired_bufsize) { + hal.console->printf("AP_Logger: reduced buffer %u/%u\n", (unsigned)bufsize, (unsigned)desired_bufsize); } if (!_writebuf.get_size()) {