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
|
||||
.utf8_text(code.as_bytes())
|
||||
.unwrap_or("malformed utf8");
|
||||
let Some(level) = LogLevel::parse(name) else {
|
||||
let Some((skip_args, level)) = LogLevel::parse(name) else {
|
||||
continue;
|
||||
};
|
||||
let line = method_call.captures[0].node.start_position().row;
|
||||
|
|
@ -132,7 +132,7 @@ impl LogExtractor {
|
|||
results.push(LogCall {
|
||||
level,
|
||||
line,
|
||||
arguments: arguments.named_child(0),
|
||||
arguments: arguments.named_child(skip_args),
|
||||
exception: None,
|
||||
});
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ fn test_extract_logging() {
|
|||
throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
|
||||
$baseMsg = 'Could not resolve ' . $name . '!';
|
||||
throw new QueryNotFoundException($baseMsg . ' ' . $e->getMessage());
|
||||
$this->log("foo %s");
|
||||
$this->log(1, "foo %s");
|
||||
}
|
||||
?>
|
||||
"#;
|
||||
|
|
|
|||
|
|
@ -18,19 +18,19 @@ pub enum LogLevel {
|
|||
}
|
||||
|
||||
impl LogLevel {
|
||||
pub fn parse(name: &str) -> Option<Self> {
|
||||
pub fn parse(name: &str) -> Option<(usize, Self)> {
|
||||
match name {
|
||||
"debug" => Some(LogLevel::Debug),
|
||||
"info" => Some(LogLevel::Info),
|
||||
"notice" => Some(LogLevel::Notice),
|
||||
"warn" | "warning" => Some(LogLevel::Warn),
|
||||
"error" => Some(LogLevel::Error),
|
||||
"alert" => Some(LogLevel::Alert),
|
||||
"critical" => Some(LogLevel::Critical),
|
||||
"emergency" => Some(LogLevel::Emergency),
|
||||
"exception" => Some(LogLevel::Exception),
|
||||
"log" => Some(LogLevel::Unknown),
|
||||
"printErrorPage" => Some(LogLevel::Unknown),
|
||||
"debug" => Some((0, LogLevel::Debug)),
|
||||
"info" => Some((0, LogLevel::Info)),
|
||||
"notice" => Some((0, LogLevel::Notice)),
|
||||
"warn" | "warning" => Some((0, LogLevel::Warn)),
|
||||
"error" => Some((0, LogLevel::Error)),
|
||||
"alert" => Some((0, LogLevel::Alert)),
|
||||
"critical" => Some((0, LogLevel::Critical)),
|
||||
"emergency" => Some((0, LogLevel::Emergency)),
|
||||
"exception" => Some((0, LogLevel::Exception)),
|
||||
"log" => Some((1, LogLevel::Unknown)),
|
||||
"printErrorPage" => Some((0, LogLevel::Unknown)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue