mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
handle sprintf logging calls
This commit is contained in:
parent
e992588923
commit
e2a09c71f5
4 changed files with 660 additions and 643 deletions
|
|
@ -246,6 +246,7 @@ fn test_extract_logging() {
|
|||
throw new \SomeException();
|
||||
$this->logger->error("foo {bar} {asd}");
|
||||
$this->logger->error($this->l10n->t("translated %s", $foo));
|
||||
throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
|
||||
}
|
||||
?>
|
||||
"#;
|
||||
|
|
@ -382,4 +383,19 @@ fn test_extract_logging() {
|
|||
]
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
logs[10],
|
||||
LoggingStatement {
|
||||
path: "foo.php",
|
||||
line: 17,
|
||||
level: LogLevel::Exception,
|
||||
has_meaningful_message: true,
|
||||
exception: Some("Test\\InvalidArgumentException".into()),
|
||||
message_parts: vec![
|
||||
MessagePart::Literal(r#"Argument ""#.into()),
|
||||
MessagePart::PlaceHolder("$key".into()),
|
||||
MessagePart::Literal(r#"" not found."#.into()),
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,12 +97,13 @@ impl MessageBuilder {
|
|||
}
|
||||
}
|
||||
}
|
||||
"member_call_expression" => {
|
||||
"member_call_expression" | "function_call_expression" => {
|
||||
match node
|
||||
.child_by_field_name("name")
|
||||
.or_else(|| node.child_by_field_name("function"))
|
||||
.and_then(|name| name.utf8_text(code.as_bytes()).ok())
|
||||
{
|
||||
Some("t") => {
|
||||
Some("t") | Some("sprintf") => {
|
||||
let arguments =
|
||||
node.child_by_field_name("arguments").expect("no arguments");
|
||||
let mut arguments = arguments.children(&mut cursor).skip(1); // opening bracket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue