diff --git a/pom.xml b/pom.xml
index 9ef5306..58131f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
nc.opt.core
opt-logging
- 3.0.1
+ 3.0.2
opt-logging
Librairie OPT de gestion des logs pour les applications du socle.
2017
@@ -23,14 +23,14 @@
UTF-8
- 1.8
+ 17
- 7.2
- 5.3.23
- 0.16
- 1.2.11
- 5.9.1
- 2.7.5
+ 7.4
+ 6.0.12
+ 0.17
+ 1.4.7
+ 5.9.2
+ 3.2.4
3.10.1
diff --git a/src/main/java/nc/opt/core/logging/LogMetierService.java b/src/main/java/nc/opt/core/logging/LogMetierService.java
index 0e2e2e5..ac86717 100644
--- a/src/main/java/nc/opt/core/logging/LogMetierService.java
+++ b/src/main/java/nc/opt/core/logging/LogMetierService.java
@@ -1,12 +1,13 @@
package nc.opt.core.logging;
-import net.logstash.logback.marker.Markers;
+import java.util.Map;
+
import org.openjdk.jol.info.GraphLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-import java.util.Map;
+import net.logstash.logback.marker.Markers;
/**
* Created by 2816ARN on 06/09/2017.
@@ -23,7 +24,8 @@ public void logObject(String objectName, Object obj) {
}
public void logObject(String objectName, String endPoint, String obj) {
- LOGGER.info(Markers.append(objectName, new LogObject(endPoint, GraphLayout.parseInstance(obj).totalSize())), MSG, objectName);
+ LOGGER.info(Markers.append(objectName, new LogObject(endPoint, GraphLayout.parseInstance(obj).totalSize())),
+ MSG, objectName);
}
public void logAttributes(Object obj) {
diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index a9f08ca..0000000
--- a/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-nc.opt.core.logging.config.LogMetierAutoConfiguration
diff --git a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..d30e3c2
--- /dev/null
+++ b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+nc.opt.core.logging.config.LogMetierAutoConfiguration
\ No newline at end of file
diff --git a/src/test/java/nc/opt/core/logging/LogMetierServiceTest.java b/src/test/java/nc/opt/core/logging/LogMetierServiceTest.java
index d098571..0ed578d 100644
--- a/src/test/java/nc/opt/core/logging/LogMetierServiceTest.java
+++ b/src/test/java/nc/opt/core/logging/LogMetierServiceTest.java
@@ -1,14 +1,7 @@
package nc.opt.core.logging;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@@ -17,16 +10,25 @@
import java.util.List;
import java.util.Map;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
@SpringBootTest(classes = LogMetierService.class)
-public class LogMetierServiceTest {
+class LogMetierServiceTest {
@Autowired
private LogMetierService service;
- private ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ private ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
+ false);
private ByteArrayOutputStream myOut;
@@ -55,43 +57,49 @@ private void assertEqualsLog(String objectName, AbstractLogObject log, TestObjec
}
@BeforeEach
- public void init() {
+ void init() {
myOut = new ByteArrayOutputStream();
System.setOut(new PrintStream(myOut));
}
@Test
- public void testLogObject() throws Exception {
+ void testLogObject() throws Exception {
TestObject obj = new TestObject("toto");
service.logObject("test", obj);
- //{"@timestamp":"2017-12-15T10:41:15.046+11:00","@version":1,"message":"add log entry for test","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":{"name":"toto"}}
- //On vérifie que les logs sont bien en JSON
+ // {"@timestamp":"2017-12-15T10:41:15.046+11:00","@version":1,"message":"add log
+ // entry for
+ // test","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":{"name":"toto"}}
+ // On vérifie que les logs sont bien en JSON
final String standardOutput = myOut.toString();
LogObject log = mapper.readValue(standardOutput, LogObject.class);
assertEqualsLog("test", log, obj);
}
@Test
- public void testLogArray() throws Exception {
+ void testLogArray() throws Exception {
TestObject obj1 = new TestObject("1");
TestObject obj2 = new TestObject("2");
- service.logArray("test", new TestObject[]{obj1, obj2});
+ service.logArray("test", (Object[]) new TestObject[] { obj1, obj2 });
- //{"@timestamp":"2017-12-15T10:55:09.564+11:00","@version":1,"message":"add log entry for test","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":[{"name":"1"},{"name":"2"}]}
- //On vérifie que les logs sont bien en JSON
+ // {"@timestamp":"2017-12-15T10:55:09.564+11:00","@version":1,"message":"add log
+ // entry for
+ // test","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":[{"name":"1"},{"name":"2"}]}
+ // On vérifie que les logs sont bien en JSON
final String standardOutput = myOut.toString();
LogArray log = mapper.readValue(standardOutput, LogArray.class);
assertEqualsLog("test", log, obj1, obj2);
}
@Test
- public void testLogAttributes() throws Exception {
+ void testLogAttributes() throws Exception {
TestObject obj1 = new TestObject("1");
service.logAttributes(obj1);
- //{"@timestamp":"2017-12-15T11:36:09.817+11:00","@version":1,"message":"add log entry for class nc.opt.core.logging.LogMetierServiceTest$TestObject","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"name":"1"}
- //On vérifie que les logs sont bien en JSON
+ // {"@timestamp":"2017-12-15T11:36:09.817+11:00","@version":1,"message":"add log
+ // entry for class
+ // nc.opt.core.logging.LogMetierServiceTest$TestObject","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"name":"1"}
+ // On vérifie que les logs sont bien en JSON
final String standardOutput = myOut.toString();
LogObject log = mapper.readValue(standardOutput, LogObject.class);
assertEqualsLog("class " + TestObject.class.getName(), log);
@@ -99,26 +107,31 @@ public void testLogAttributes() throws Exception {
}
@Test
- public void testLogJson() throws Exception {
+ void testLogJson() throws Exception {
TestObject obj1 = new TestObject("1");
service.logJson("test", mapper.writeValueAsString(obj1));
- //{"@timestamp":"2017-12-15T11:55:05.818+11:00","@version":1,"message":"add log entry for test","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":{"name":"1"}}
- //On vérifie que les logs sont bien en JSON
+ // {"@timestamp":"2017-12-15T11:55:05.818+11:00","@version":1,"message":"add log
+ // entry for
+ // test","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":{"name":"1"}}
+ // On vérifie que les logs sont bien en JSON
final String standardOutput = myOut.toString();
LogObject log = mapper.readValue(standardOutput, LogObject.class);
assertEqualsLog("test", log, obj1);
}
@Test
- public void testLogEntries() throws Exception {
+ void testLogEntries() throws Exception {
TestObject obj1 = new TestObject("1");
Map entries = new HashMap<>();
entries.put("test", obj1);
service.logEntries(entries);
- //{"@timestamp":"2017-12-15T11:59:09.672+11:00","@version":1,"message":"add log entry for map","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":{"name":"1"}}
- //On vérifie que les logs sont bien en JSON
+ // {"@timestamp":"2017-12-15T11:59:09.672+11:00","@version":1,"message":"add log
+ // entry for
+ // map","logger_name":"metiersLogger","thread_name":"main","level":"INFO","level_value":20000,"test":{"name":"1"}}
+
+ // On vérifie que les logs sont bien en JSON
final String standardOutput = myOut.toString();
LogObject log = mapper.readValue(standardOutput, LogObject.class);
assertEqualsLog("map", log, obj1);
@@ -151,7 +164,6 @@ static abstract class AbstractLogObject {
private String level;
@JsonProperty("level_value")
private Integer levelValue;
-
public AbstractLogObject() {
}
@@ -170,7 +182,7 @@ public LogObject() {
}
@JsonAnySetter
- public void set(String fieldName, Object value) {
+ void set(String fieldName, Object value) {
this.attributes.put(fieldName, value);
}
}