mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Use host max log level when initializing the RuntimeLogger (#8655)
* Use host max log level when initializing the `RuntimeLogger` This should fix performance problems introduced by logging under certain circumstances. Before we always called into the host and the host was doing the log filtering, now as the correct max log level is set, we don't call into the host for every log line to check if it should be logged. However, we would still call into the host to determine if something should be logged when `something=trace` is given as we don't forward the log targets that are enabled. * Finish the pr
This commit is contained in:
@@ -281,7 +281,7 @@ pub trait TypeId {
|
||||
|
||||
/// A log level matching the one from `log` crate.
|
||||
///
|
||||
/// Used internally by `sp_io::log` method.
|
||||
/// Used internally by `sp_io::logging::log` method.
|
||||
#[derive(Encode, Decode, PassByEnum, Copy, Clone)]
|
||||
pub enum LogLevel {
|
||||
/// `Error` log level.
|
||||
@@ -334,6 +334,53 @@ impl From<LogLevel> for log::Level {
|
||||
}
|
||||
}
|
||||
|
||||
/// Log level filter that expresses which log levels should be filtered.
|
||||
///
|
||||
/// This enum matches the [`log::LogLevelFilter`] enum.
|
||||
#[derive(Encode, Decode, PassByEnum, Copy, Clone)]
|
||||
pub enum LogLevelFilter {
|
||||
/// `Off` log level filter.
|
||||
Off = 0,
|
||||
/// `Error` log level filter.
|
||||
Error = 1,
|
||||
/// `Warn` log level filter.
|
||||
Warn = 2,
|
||||
/// `Info` log level filter.
|
||||
Info = 3,
|
||||
/// `Debug` log level filter.
|
||||
Debug = 4,
|
||||
/// `Trace` log level filter.
|
||||
Trace = 5,
|
||||
}
|
||||
|
||||
impl From<LogLevelFilter> for log::LevelFilter {
|
||||
fn from(l: LogLevelFilter) -> Self {
|
||||
use self::LogLevelFilter::*;
|
||||
match l {
|
||||
Off => Self::Off,
|
||||
Error => Self::Error,
|
||||
Warn => Self::Warn,
|
||||
Info => Self::Info,
|
||||
Debug => Self::Debug,
|
||||
Trace => Self::Trace,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<log::LevelFilter> for LogLevelFilter {
|
||||
fn from(l: log::LevelFilter) -> Self {
|
||||
use log::LevelFilter::*;
|
||||
match l {
|
||||
Off => Self::Off,
|
||||
Error => Self::Error,
|
||||
Warn => Self::Warn,
|
||||
Info => Self::Info,
|
||||
Debug => Self::Debug,
|
||||
Trace => Self::Trace,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Encodes the given value into a buffer and returns the pointer and the length as a single `u64`.
|
||||
///
|
||||
/// When Substrate calls into Wasm it expects a fixed signature for functions exported
|
||||
|
||||
Reference in New Issue
Block a user