-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fatxpool
: use tracing for logging (#6897)
This PR modifies the fatxpool to use tracing instead of log for logging. closes #5490 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
- Loading branch information
1 parent
e9e4251
commit 07d4b46
Showing
16 changed files
with
755 additions
and
308 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
title: 'Tracing Log for fork-aware transaction pool' | ||
doc: | ||
- audience: Node Dev | ||
description: Replacement of log crate with tracing crate for better logging. | ||
crates: | ||
- name: sc-transaction-pool | ||
bump: minor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
substrate/client/transaction-pool/src/common/tracing_log_xt.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
//! Utility for logging transaction collections with tracing crate. | ||
/// Logs every transaction from given `tx_collection` with given level. | ||
macro_rules! log_xt { | ||
(data: hash, target: $target:expr, $level:expr, $tx_collection:expr, $text_with_format:expr) => { | ||
for tx in $tx_collection { | ||
tracing::event!( | ||
$level, | ||
target = $target, | ||
tx_hash = format!("{:?}", tx), | ||
$text_with_format, | ||
); | ||
} | ||
}; | ||
(data: hash, target: $target:expr, $level:expr, $tx_collection:expr, $text_with_format:expr, $($arg:expr),*) => { | ||
for tx in $tx_collection { | ||
tracing::event!( | ||
$level, | ||
target = $target, | ||
tx_hash = format!("{:?}", tx), | ||
$text_with_format, | ||
$($arg),* | ||
); | ||
} | ||
}; | ||
(data: tuple, target: $target:expr, $level:expr, $tx_collection:expr, $text_with_format:expr) => { | ||
for tx in $tx_collection { | ||
tracing::event!( | ||
$level, | ||
target = $target, | ||
tx_hash = format!("{:?}", tx.0), | ||
$text_with_format, | ||
tx.1 | ||
); | ||
} | ||
}; | ||
} | ||
macro_rules! log_xt_trace { | ||
(data: $datatype:ident, target: $target:expr, $($arg:tt)+) => { | ||
$crate::common::tracing_log_xt::log_xt!(data: $datatype, target: $target, tracing::Level::TRACE, $($arg)+); | ||
}; | ||
(target: $target:expr, $tx_collection:expr, $text_with_format:expr) => { | ||
$crate::common::tracing_log_xt::log_xt!(data: hash, target: $target, tracing::Level::TRACE, $tx_collection, $text_with_format); | ||
}; | ||
(target: $target:expr, $tx_collection:expr, $text_with_format:expr, $($arg:expr)*) => { | ||
$crate::common::tracing_log_xt::log_xt!(data: hash, target: $target, tracing::Level::TRACE, $tx_collection, $text_with_format, $($arg)*); | ||
}; | ||
} | ||
|
||
pub(crate) use log_xt; | ||
pub(crate) use log_xt_trace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.