mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
handle sprintf logging calls
This commit is contained in:
parent
e992588923
commit
e2a09c71f5
4 changed files with 660 additions and 643 deletions
|
|
@ -203,7 +203,7 @@ pub const STATEMENTS: &[crate::LoggingStatement] = &[
|
|||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/composer/InstalledVersions.php" , line : 203usize , placeholders : & ["$packageName"] , exception : Some ("OutOfBoundsException") , pattern : "Package \"\0\" is not installed\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/composer/InstalledVersions.php" , line : 224usize , placeholders : & ["$packageName"] , exception : Some ("OutOfBoundsException") , pattern : "Package \"\0\" is not installed\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/composer/InstalledVersions.php" , line : 241usize , placeholders : & ["$packageName"] , exception : Some ("OutOfBoundsException") , pattern : "Package \"\0\" is not installed\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php" , line : 57usize , placeholders : & ["sprintf('Error validating %s: %s', $error['pointer'], $error['message'])"] , exception : Some ("JsonSchema\\Exception\\ValidationException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php" , line : 57usize , placeholders : & ["$error['pointer']" , "$error['message']"] , exception : Some ("JsonSchema\\Exception\\ValidationException") , pattern : "Error validating \0: \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php" , line : 143usize , placeholders : & ["$message"] , exception : Some ("JsonSchema\\Exception\\InvalidArgumentException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.php" , line : 168usize , placeholders : & ["$name"] , exception : Some ("JsonSchema\\Exception\\InvalidArgumentException") , pattern : "Unknown constraint \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.php" , line : 172usize , placeholders : & ["$name"] , exception : Some ("JsonSchema\\Exception\\InvalidArgumentException") , pattern : "Invalid class \0\u{1}\u{1}" , },
|
||||
|
|
@ -211,19 +211,19 @@ pub const STATEMENTS: &[crate::LoggingStatement] = &[
|
|||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php" , line : 40usize , placeholders : & [] , exception : Some ("JsonSchema\\Exception\\InvalidArgumentException") , pattern : "no schema found to verify against\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php" , line : 52usize , placeholders : & [] , exception : Some ("JsonSchema\\Exception\\RuntimeException") , pattern : "Cannot validate the schema of a non-object\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php" , line : 79usize , placeholders : & [] , exception : Some ("JsonSchema\\Exception\\InvalidSchemaException") , pattern : "Schema did not pass validation\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php" , line : 138usize , placeholders : & ["sprintf( 'No wording for %s available, expected wordings are: [%s]', var_export($type, true), implode(', ', array_filter(self::$wording)))"] , exception : Some ("UnexpectedValueException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php" , line : 138usize , placeholders : & ["var_export($type, true)" , "implode(', ', array_filter(self::$wording))"] , exception : Some ("UnexpectedValueException") , pattern : "No wording for \0 available, expected wordings are: [\0]\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php" , line : 214usize , placeholders : & ["(is_object($value) ? 'object' : $value)" , "$type"] , exception : Some ("JsonSchema\\Exception\\InvalidArgumentException") , pattern : "\0 is an invalid type for \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.php" , line : 40usize , placeholders : & [] , exception : Some ("JsonSchema\\Exception\\InvalidArgumentException") , pattern : "Ref value must be a string\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php" , line : 131usize , placeholders : & ["sprintf( \"Could not resolve fragment '%s': no file is defined\", $jsonPointer->getPropertyPathAsString() )"] , exception : Some ("JsonSchema\\Exception\\UnresolvableJsonPointerException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php" , line : 145usize , placeholders : & ["sprintf( 'File: %s is found, but could not resolve fragment: %s', $jsonPointer->getFilename(), $jsonPointer->getPropertyPathAsString() )"] , exception : Some ("JsonSchema\\Exception\\UnresolvableJsonPointerException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php" , line : 131usize , placeholders : & ["$jsonPointer->getPropertyPathAsString()"] , exception : Some ("JsonSchema\\Exception\\UnresolvableJsonPointerException") , pattern : "Could not resolve fragment '\0': no file is defined\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php" , line : 145usize , placeholders : & ["$jsonPointer->getFilename()" , "$jsonPointer->getPropertyPathAsString()"] , exception : Some ("JsonSchema\\Exception\\UnresolvableJsonPointerException") , pattern : "File: \0 is found, but could not resolve fragment: \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php" , line : 28usize , placeholders : & [] , exception : Some ("JsonSchema\\Exception\\RuntimeException") , pattern : "cURL not installed\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php" , line : 48usize , placeholders : & [] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "JSON schema not found\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php" , line : 38usize , placeholders : & ["$errorMessage"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php" , line : 42usize , placeholders : & ["$uri"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "JSON schema not found at \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php" , line : 48usize , placeholders : & ["$uri"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "JSON schema not found at \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php" , line : 48usize , placeholders : & ["sprintf( 'The JSON schema \"%s\" was not found.', $uri )"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php" , line : 140usize , placeholders : & ["sprintf(\"Unable to resolve URI '%s' from base '%s'\", $relativePath, $basePath)"] , exception : Some ("JsonSchema\\Exception\\UriResolverException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php" , line : 92usize , placeholders : & ["sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE)"] , exception : Some ("JsonSchema\\Exception\\InvalidSchemaMediaTypeException") , pattern : "\0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php" , line : 48usize , placeholders : & ["$uri"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "The JSON schema \"\0\" was not found.\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php" , line : 140usize , placeholders : & ["$relativePath" , "$basePath"] , exception : Some ("JsonSchema\\Exception\\UriResolverException") , pattern : "Unable to resolve URI '\0' from base '\0'\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php" , line : 92usize , placeholders : & ["Validator::SCHEMA_MEDIA_TYPE"] , exception : Some ("JsonSchema\\Exception\\InvalidSchemaMediaTypeException") , pattern : "Media type \0 expected\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php" , line : 143usize , placeholders : & ["$parsed['fragment']" , "$uri"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "Fragment \"\0\" not found in \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php" , line : 150usize , placeholders : & ["$pathElement" , "$uri"] , exception : Some ("JsonSchema\\Exception\\ResourceNotFoundException") , pattern : "Fragment part \"\0\" is no object in \0\u{1}\u{1}" , },
|
||||
crate :: LoggingStatement { level : crate :: LogLevel :: Exception , path : "/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php" , line : 213usize , placeholders : & ["$error"] , exception : Some ("JsonSchema\\Exception\\JsonDecodingException") , pattern : "\0\u{1}\u{1}" , },
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -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