Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.1] set prune logs at debug level except for the initial log when enabling pruning #718

Merged
merged 3 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions libraries/chain/block_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace eosio { namespace chain {

void append(const signed_block_ptr& b);

void prune();
void prune(const fc::log_level& loglevel);

void vacuum();

Expand Down Expand Up @@ -331,7 +331,7 @@ namespace eosio { namespace chain {

if(!is_currently_pruned && my->prune_config) {
//need to convert non-pruned log to pruned log. prune any blocks to start with
my->prune();
my->prune(fc::log_level::info);

//update version
my->block_file.seek(0);
Expand Down Expand Up @@ -387,7 +387,7 @@ namespace eosio { namespace chain {

if(prune_config) {
if((pos&prune_config->prune_threshold) != (end&prune_config->prune_threshold))
prune();
prune(fc::log_level::debug);

const uint32_t num_blocks_in_log = chain::block_header::num_from_id(head_id) - first_block_num + 1;
fc::raw::pack(block_file, num_blocks_in_log);
Expand All @@ -398,7 +398,7 @@ namespace eosio { namespace chain {
FC_LOG_AND_RETHROW()
}

void detail::block_log_impl::prune() {
void detail::block_log_impl::prune(const fc::log_level& loglevel) {
if(!head)
return;
const uint32_t head_num = chain::block_header::num_from_id(head_id);
Expand All @@ -418,7 +418,8 @@ namespace eosio { namespace chain {
first_block_num = prune_to_num;
block_file.flush();

ilog("blocks.log pruned to blocks ${b}-${e}", ("b", first_block_num)("e", head_num));
fc::log_message(fc::log_context(loglevel, __FILE__, __LINE__, __func__),
"blocks.log pruned to blocks ${b}-${e}", fc::mutable_variant_object()("b", first_block_num)("e", head_num));
spoonincode marked this conversation as resolved.
Show resolved Hide resolved
}

void block_log::flush() {
Expand Down
9 changes: 5 additions & 4 deletions libraries/state_history/include/eosio/state_history/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class state_history_log {

if((is_ship_log_pruned(first_header.magic) == false) && prune_config) {
//need to convert non-pruned to pruned; first prune any ranges we can (might be none)
prune();
prune(fc::log_level::info);

//update first header to indicate prune feature is enabled
log.seek(0);
Expand Down Expand Up @@ -200,7 +200,7 @@ class state_history_log {

if(prune_config) {
if((pos&prune_config->prune_threshold) != (log.tellp()&prune_config->prune_threshold))
prune();
prune(fc::log_level::debug);

const uint32_t num_blocks_in_log = _end_block - _begin_block;
fc::raw::pack(log, num_blocks_in_log);
Expand Down Expand Up @@ -250,7 +250,7 @@ class state_history_log {
return true;
}

void prune() {
void prune(const fc::log_level& loglevel) {
if(!prune_config)
return;
if(_end_block - _begin_block <= prune_config->prune_blocks)
Expand All @@ -264,7 +264,8 @@ class state_history_log {
_begin_block = prune_to_num;
log.flush();

ilog("${name}.log pruned to blocks ${b}-${e}", ("name", name)("b", _begin_block)("e", _end_block - 1));
fc::log_message(fc::log_context(loglevel, __FILE__, __LINE__, __func__),
"${name}.log pruned to blocks ${b}-${e}", fc::mutable_variant_object()("name", name)("b", _begin_block)("e", _end_block - 1));
spoonincode marked this conversation as resolved.
Show resolved Hide resolved
}

//only works on non-pruned logs
Expand Down