Skip to content

Commit

Permalink
move transaction logging to logger-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Yair Ogen committed Aug 9, 2016
1 parent 53b7169 commit 83dea3e
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 33 deletions.
53 changes: 51 additions & 2 deletions logging-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<properties>
<foundation-common-base-version>1.0.1-5</foundation-common-base-version>
<slf4j-version>1.7.21</slf4j-version>
<!--<javaVersion>1.6</javaVersion>-->
</properties>
<parent>
<groupId>com.cisco.oss.foundation</groupId>
<artifactId>foundation-common-base</artifactId>
<version>1.0.1-7</version>
<version>1.0.1-8</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.cisco.oss.foundation</groupId>
<artifactId>logging-api</artifactId>
<name>logging-api</name>
<version>1.0.2-3-SNAPSHOT</version>
<version>1.1.0-1-SNAPSHOT</version>
<description>This project is the logging api library in the cisco vss foundation runtime</description>
<url>https://github.com/foundation-runtime/logging/tree/master/logging-api</url>
<packaging>jar</packaging>
Expand Down Expand Up @@ -92,6 +93,15 @@
<plugins>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jdom</groupId>
Expand All @@ -108,5 +118,44 @@
<artifactId>reflections</artifactId>
<version>0.9.8</version>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc2</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>javawriter</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>3.0.12.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.0.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.cisco.oss.foundation</groupId>
<artifactId>configuration-api</artifactId>
<version>1.0.2-4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public enum ConfigurationUtil implements FoundationConfigurationListener {
private Environment environment;

ConfigurationUtil() {
refresh();

}

@Override
public void configurationChanged() {
refresh();
reloadConfig();
}

private void refresh() {
private void reloadConfig() {
if (environment == null) {
verbose = ConfigurationFactory.getConfiguration().getBoolean("logging.verbose", false);
}else{
Expand Down Expand Up @@ -56,5 +56,7 @@ public static void setConfigSource(Environment environment) {
if (environment != null && !configuredReady){
INSTANCE.setEnvironment(environment);
}

INSTANCE.reloadConfig();
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package com.cisco.oss.foundation.logging.transactions;

import com.cisco.oss.foundation.configuration.ConfigurationFactory;
import org.apache.commons.configuration.Configuration;
import com.cisco.oss.foundation.flowcontext.FlowContextFactory;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.slf4j.Logger;

import com.cisco.oss.foundation.flowcontext.FlowContextFactory;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.*;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
Expand All @@ -28,7 +24,6 @@
* @author abrandwi
*
*/
@org.springframework.stereotype.Component
public class HttpLogger extends TransactionLogger {


Expand All @@ -42,6 +37,11 @@ private enum HttpVerbosePropertyKey {RequestHeaders, RequestBody, ResponseHeader
private Environment environment;

public HttpLogger(){

}

@PostConstruct
public void init(){
ConfigurationUtil.setConfigSource(environment);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.cisco.oss.foundation.logging.transactions;

import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;

public class HttpResponse {

private String body;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.cisco.oss.foundation.logging.transactions;

import com.cisco.oss.foundation.configuration.ConfigurationFactory;
import com.google.common.base.Joiner;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.slf4j.event.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.*;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
Expand All @@ -22,7 +21,6 @@
*
* @author abrandwi
*/
@org.springframework.stereotype.Component
public class HttpSpringLogger extends TransactionLogger {

private enum HttpPropertyKey {Summary, Method, SourceName, SourcePort, URL, ResponseStatusCode, ResponseContentLength, ResponseBody}
Expand All @@ -34,6 +32,11 @@ private enum HttpVerbosePropertyKey {RequestHeaders, RequestBody, ResponseHeader
private Environment environment;

public HttpSpringLogger(){

}

@PostConstruct
public void init(){
ConfigurationUtil.setConfigSource(environment);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.cisco.oss.foundation.logging.transactions;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.slf4j.event.Level;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.*;

import javax.annotation.PostConstruct;

/**
* Class for MessageQueue transactions logging
* @author abrandwi
*
*/
@org.springframework.stereotype.Component
public class MessageQueueLogger extends TransactionLogger {

private enum MessageQueuePropertyKey {NotificationType};
Expand All @@ -24,6 +24,11 @@ private enum MessageQueueVerbosePropertyKey {NotificationBody};
private Environment environment;

public MessageQueueLogger(){

}

@PostConstruct
public void init(){
ConfigurationUtil.setConfigSource(environment);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cisco.oss.foundation.logging.transactions;

import org.apache.log4j.Level;
import org.slf4j.event.Level;
import org.slf4j.Logger;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cisco.oss.foundation.logging.transactions;

import org.apache.log4j.Level;
import org.slf4j.event.Level;
import org.slf4j.Logger;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.cisco.oss.foundation.logging.transactions;

import com.cisco.oss.foundation.flowcontext.FlowContextFactory;
import com.cisco.oss.foundation.ip.utils.IpUtils;
import org.slf4j.event.Level;
import org.slf4j.Logger;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.log4j.Level;
import org.slf4j.Logger;

import com.cisco.oss.foundation.flowcontext.FlowContextFactory;
import com.cisco.oss.foundation.ip.utils.IpUtils;

/**
* Abstract class for transactions logging
* @author abrandwi
Expand Down Expand Up @@ -188,7 +187,6 @@ public static void addProperty(String key, String value) {
* @param logger
* @param auditor
* @param instance
* @param flowContextId
* @return whether new instance was set to thread-local
*/
protected static boolean createLoggingAction(final Logger logger, final Logger auditor, final TransactionLogger instance) {
Expand Down
2 changes: 1 addition & 1 deletion logging-log4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<groupId>com.cisco.oss.foundation</groupId>
<artifactId>logging-log4j</artifactId>
<name>logging-log4j</name>
<version>1.1.1-2-SNAPSHOT</version>
<version>1.2.1-0-SNAPSHOT</version>
<description>This project is the logging log4j implementation library in the cisco vss foundation runtime
</description>
<url>https://github.com/foundation-runtime/logging/tree/master/logging-log4j</url>
Expand Down

0 comments on commit 83dea3e

Please sign in to comment.