mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
fix extracting dynamic log level calls
This commit is contained in:
parent
550f507687
commit
2847776d9d
3 changed files with 1169 additions and 1169 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -123,7 +123,7 @@ impl LogExtractor {
|
||||||
.node
|
.node
|
||||||
.utf8_text(code.as_bytes())
|
.utf8_text(code.as_bytes())
|
||||||
.unwrap_or("malformed utf8");
|
.unwrap_or("malformed utf8");
|
||||||
let Some(level) = LogLevel::parse(name) else {
|
let Some((skip_args, level)) = LogLevel::parse(name) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let line = method_call.captures[0].node.start_position().row;
|
let line = method_call.captures[0].node.start_position().row;
|
||||||
|
|
@ -132,7 +132,7 @@ impl LogExtractor {
|
||||||
results.push(LogCall {
|
results.push(LogCall {
|
||||||
level,
|
level,
|
||||||
line,
|
line,
|
||||||
arguments: arguments.named_child(0),
|
arguments: arguments.named_child(skip_args),
|
||||||
exception: None,
|
exception: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +284,7 @@ fn test_extract_logging() {
|
||||||
throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
|
throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
|
||||||
$baseMsg = 'Could not resolve ' . $name . '!';
|
$baseMsg = 'Could not resolve ' . $name . '!';
|
||||||
throw new QueryNotFoundException($baseMsg . ' ' . $e->getMessage());
|
throw new QueryNotFoundException($baseMsg . ' ' . $e->getMessage());
|
||||||
$this->log("foo %s");
|
$this->log(1, "foo %s");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
"#;
|
"#;
|
||||||
|
|
|
||||||
|
|
@ -18,19 +18,19 @@ pub enum LogLevel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogLevel {
|
impl LogLevel {
|
||||||
pub fn parse(name: &str) -> Option<Self> {
|
pub fn parse(name: &str) -> Option<(usize, Self)> {
|
||||||
match name {
|
match name {
|
||||||
"debug" => Some(LogLevel::Debug),
|
"debug" => Some((0, LogLevel::Debug)),
|
||||||
"info" => Some(LogLevel::Info),
|
"info" => Some((0, LogLevel::Info)),
|
||||||
"notice" => Some(LogLevel::Notice),
|
"notice" => Some((0, LogLevel::Notice)),
|
||||||
"warn" | "warning" => Some(LogLevel::Warn),
|
"warn" | "warning" => Some((0, LogLevel::Warn)),
|
||||||
"error" => Some(LogLevel::Error),
|
"error" => Some((0, LogLevel::Error)),
|
||||||
"alert" => Some(LogLevel::Alert),
|
"alert" => Some((0, LogLevel::Alert)),
|
||||||
"critical" => Some(LogLevel::Critical),
|
"critical" => Some((0, LogLevel::Critical)),
|
||||||
"emergency" => Some(LogLevel::Emergency),
|
"emergency" => Some((0, LogLevel::Emergency)),
|
||||||
"exception" => Some(LogLevel::Exception),
|
"exception" => Some((0, LogLevel::Exception)),
|
||||||
"log" => Some(LogLevel::Unknown),
|
"log" => Some((1, LogLevel::Unknown)),
|
||||||
"printErrorPage" => Some(LogLevel::Unknown),
|
"printErrorPage" => Some((0, LogLevel::Unknown)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue