From b4f554b047bcd18261895ccd3a1590c18a2f291b Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Tue, 6 Feb 2024 09:43:16 +0100 Subject: [PATCH] cleanup logging & adjust log levels --- .../aas4j/v3/dataformat/aasx/AASXDeserializer.java | 4 ++-- .../digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java | 4 ++-- .../aas4j/v3/dataformat/core/util/ReflectionHelper.java | 2 +- .../aas4j/v3/dataformat/xml/XmlSerializerTest.java | 2 +- .../aas4j/v3/dataformat/xml/XmlValidationTest.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java index 069e64cd7..111f140cc 100644 --- a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java +++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXDeserializer.java @@ -130,7 +130,7 @@ public List getRelatedFiles() throws InvalidFormatException, IOExc try { files.add(readFile(aasxRoot, filePath)); } catch (Exception e) { - logger.warn("Loading file " + filePath + " failed and will not be included. Exception: " + e); + logger.warn("Loading file {} failed and will not be included.", filePath, e); } } return files; @@ -168,7 +168,7 @@ private PackageRelationshipCollection getXMLDocumentRelation(PackagePart originP private String getXMLPart(PackagePart originPart) throws InvalidFormatException { if (isCompatibilityModeNeeded(originPart)) { - logger.warn("AASX contains wrong Relationship namespace. This may be related to the AASX being created with an old version of AASX Package Explorer or an old version of AAS4J. Future compatibility with the wrong namespace may not be guaranteed"); + logger.info("AASX contains wrong Relationship namespace. This may be related to the AASX being created with an old version of AASX Package Explorer or an old version of AAS4J. Future compatibility with the wrong namespace may not be guaranteed"); return AASPEC_RELTYPE_BACKWARDSCOMPATIBLE; } else { return AASXSerializer.AASSPEC_RELTYPE; diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java index a287b121e..b8d13befd 100644 --- a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java +++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java @@ -147,11 +147,11 @@ private void createParts(Collection files, String filePath, OPCPac PackagePart xmlPart, String contentType) { try { InMemoryFile content = findFileByPath(files, filePath); - logger.trace("Writing file '" + filePath + "' to .aasx."); + logger.trace("Writing file '{}' to .aasx.", filePath); createAASXPart(rootPackage, xmlPart, filePath, contentType, AASSUPPL_RELTYPE, content.getFileContent()); } catch (RuntimeException e) { // Log that a file is missing and continue building the .aasx - logger.warn("Could not add File '" + filePath + "'. It was not contained in given InMemoryFiles."); + logger.warn("Could not add File '{}'. It was not contained in given InMemoryFiles.", filePath, e); } } diff --git a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java index b69025640..41b64858a 100644 --- a/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java +++ b/dataformat-core/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/util/ReflectionHelper.java @@ -216,7 +216,7 @@ public static Class getAasInterface(Class type) { if (implementedAasInterfaces.size() == 1) { return implementedAasInterfaces.iterator().next(); } - logger.warn("class '{}' implements more than one AAS interface, but only most specific one is returned", type.getName()); + logger.debug("class '{}' implements more than one AAS interface, but only most specific one is returned", type.getName()); return implementedAasInterfaces.stream().map(x -> TypeToken.of(x)) .sorted(new MostSpecificTypeTokenComparator()) .findFirst().get() diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java index 469a163df..47c409603 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java @@ -290,7 +290,7 @@ private boolean ignoreDefaults(Node node) { private void logErrors(String validatedFileName, Set errors) { if (errors.isEmpty()) return; - logger.info("Validate file: " + validatedFileName); + logger.info("Validate file: {}", validatedFileName); for (String error : errors) { logger.info(error); } diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java index 67940aa60..9745b7eb6 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java @@ -66,7 +66,7 @@ private void logErrors(String validatedFileName, Set errors) { if (errors.isEmpty()) { return; } - logger.info("Validate file: " + validatedFileName); + logger.info("Validate file: {}", validatedFileName); for (String error : errors) { logger.info(error); }