Skip to content

Commit

Permalink
log: Make log_max_recent have an effect again.
Browse files Browse the repository at this point in the history
The log improvements in a747aea
unfortunately left log_max_recent broken because m_max_recent wasn't
used anymore.

Eliminate m_max_recent and set the capacity of the m_recent ring buffer
when log_max_recent changes. In order to call set_capacity(),
ConcreteEntry needed its move constructor set noexcept.

I haven't followed the boost code all the way down but I suspect that
setting the ring buffer capacity to anything less than 1 entry will
probably cause problems, so restrict log_max_recent to >=1.

Also fix a wrong variable used for printing the max new entries during
"log dump".

Signed-off-by: Joshua Baergen <jbaergen@digitalocean.com>
(cherry picked from commit 3d59ba1)

Conflicts:
  - file: src/common/options/global.yaml.in
    desc: not exists in pacific?
  • Loading branch information
Joshua Baergen authored and k0ste committed Oct 14, 2023
1 parent 129959f commit 26ebd65
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/log/Entry.h
Expand Up @@ -90,7 +90,7 @@ class ConcreteEntry : public Entry {
str.assign(strv.begin(), strv.end());
return *this;
}
ConcreteEntry(ConcreteEntry&& e) : Entry(e), str(std::move(e.str)) {}
ConcreteEntry(ConcreteEntry&& e) noexcept : Entry(e), str(std::move(e.str)) {}
ConcreteEntry& operator=(ConcreteEntry&& e) {
Entry::operator=(e);
str = std::move(e.str);
Expand Down
6 changes: 3 additions & 3 deletions src/log/Log.cc
Expand Up @@ -132,7 +132,7 @@ void Log::set_max_new(std::size_t n)
void Log::set_max_recent(std::size_t n)
{
std::scoped_lock lock(m_flush_mutex);
m_max_recent = n;
m_recent.set_capacity(n);
}

void Log::set_log_file(std::string_view fn)
Expand Down Expand Up @@ -490,8 +490,8 @@ void Log::dump_recent()
tid_to_int(pthread_id), pthread_name), true);
}

_log_message(fmt::format(" max_recent {:9}", m_max_recent), true);
_log_message(fmt::format(" max_new {:9}", m_max_recent), true);
_log_message(fmt::format(" max_recent {:9}", m_recent.capacity()), true);
_log_message(fmt::format(" max_new {:9}", m_max_new), true);
_log_message(fmt::format(" log_file {}", m_log_file), true);

_log_message("--- end dump of recent events ---", true);
Expand Down
1 change: 0 additions & 1 deletion src/log/Log.h
Expand Up @@ -116,7 +116,6 @@ class Log : private Thread
bool m_stop = false;

std::size_t m_max_new = DEFAULT_MAX_NEW;
std::size_t m_max_recent = DEFAULT_MAX_RECENT;

bool m_inject_segv = false;

Expand Down

0 comments on commit 26ebd65

Please sign in to comment.