Reduced content of MsoLogger
[so.git] / common / src / main / java / org / onap / so / logger / MsoLogger.java
index 94ffa71..f8ff530 100644 (file)
@@ -74,6 +74,7 @@ public class MsoLogger {
     public static final String ONAP_REQUEST_ID            = "X-ONAP-RequestID";
     public static final String CLIENT_ID                   = "X-ClientID";
     public static final String INVOCATION_ID_HEADER        = "X-InvocationID";
+    public static final String REQUESTOR_ID                = "X-RequestorID";
     
     //Default values for not found
     public static final String UNKNOWN_PARTNER                 = "UnknownPartner";
@@ -95,12 +96,6 @@ public class MsoLogger {
 
     public static final String PARTNER_NAME                 = "PartnerName";
 
-    
-
-
-    
-
-    
     // Audit/Metric log specific
     public static final String BEGINTIME                   = "BeginTimestamp";
     public static final String STARTTIME                   = "StartTimeMilis";
@@ -183,9 +178,7 @@ public class MsoLogger {
             this.value = value;
         }
     }
-    
-    public static final Marker ENTRY = MarkerFactory.getMarker("ENTRY");
-    public static final Marker EXIT = MarkerFactory.getMarker("EXIT");
+
 
     private Logger logger;
     private Logger metricsLogger;
@@ -193,9 +186,6 @@ public class MsoLogger {
     private static String       instanceUUID, serverIP, serverName;
     private MessageEnum         exceptionArg, defaultException, defaultWarning, defaultAudit, defaultMetrics;
 
-    // For internal logging of the initialization of MSO logs
-    private static final Logger initLOGGER      = LoggerFactory.getLogger(MsoLogger.class.getName());
-
     private MsoLogger() {
         this(MsoLogger.Catalog.GENERAL);
     }
@@ -207,30 +197,9 @@ public class MsoLogger {
     private MsoLogger(MsoLogger.Catalog cat, Class<?> clazz) {
         this.logger = LoggerFactory.getLogger(clazz);
         this.auditLogger = LoggerFactory.getLogger("AUDIT");
-        this.metricsLogger = LoggerFactory.getLogger("METRIC");
-        MsoLogger.initialization();       
+        this.metricsLogger = LoggerFactory.getLogger("METRIC");       
         setDefaultLogCatalog(cat);
     }
-
-    private static synchronized void initialization() {
-        if (instanceUUID == null || ("").equals(instanceUUID)) {
-            instanceUUID = getInstanceUUID();
-        }
-
-        if (serverIP == null || serverName == null || ("").equals(serverIP) || ("").equals(serverName)) {
-            try {
-                InetAddress server = InetAddress.getLocalHost();
-                serverIP = server.getHostAddress();
-                serverName = server.getHostName();
-            } catch (UnknownHostException e) {
-                initLOGGER.error("Could not get local hostname", e);
-                serverIP = "";
-                serverName = "";
-            }
-        }
-    }
-
-
     
     public static MsoLogger getMsoLogger(MsoLogger.Catalog cat, Class<?> clazz) {
         return new MsoLogger(cat,clazz);
@@ -256,12 +225,6 @@ public class MsoLogger {
      * @param targetVEntity
      *            Target VNF or VM acted opon by the component, if available
      */
-    public void recordMetricEvent() {
-        metricsLogger.info("");
-        MDC.remove(TIMER);
-        MDC.remove(TARGETENTITY);
-        MDC.remove(TARGETSERVICENAME);
-    }
 
     public void recordMetricEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode, String responseDesc,
             String targetEntity, String targetServiceName, String targetVEntity) {
@@ -286,10 +249,7 @@ public class MsoLogger {
      * @param responseDesc
      *            Human redable description of the application response code
      */
-    public void recordAuditEvent(){            
-         auditLogger.info("");
-    }
-    
+
     public void recordAuditEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode,
             String responseDesc) {
        if (StringUtils.isEmpty(MDC.get(MsoLogger.PARTNERNAME))) {
@@ -928,16 +888,6 @@ public class MsoLogger {
                MDC.remove(TARGETSERVICENAME);
                
        }
-    
-    public void logStackTrace(Exception ex){
-       StringWriter errors = new StringWriter();
-       ex.printStackTrace(new PrintWriter(errors));
-       logger.error(errors.toString());
-    }
-
-    public boolean isDebugEnabled() {
-        return logger.isDebugEnabled();
-    }
 
     private void prepareMsg(String loggingLevel) {
         prepareMsg(loggingLevel, null, null);
@@ -999,7 +949,6 @@ public class MsoLogger {
         MDC.put(ERRORDESC, errorDesc);
         MDC.put(TARGETENTITY, targetEntity);
         MDC.put(TARGETSERVICENAME, targetServiceName);
-        MDC.put(SERVICE_NAME, getFinalServiceName(getServiceName()));
     }
 
     private void prepareMetricMsg(long startTime, StatusCode statusCode, int responseCode, String responseDesc,
@@ -1080,18 +1029,9 @@ public class MsoLogger {
         return classArr[0].getMethodName();
     }
 
-    // Based on the discussion with Adrian, instanceUUID is used to identifiy
-    // the mso instance,
-    // it is generated during mso instance initialization period
-    // The same mso instnace will use the same instanceUUID value, even after
-    // restart
-    private static String getInstanceUUID() {       
-       return System.getProperty("mso-instance-id");
-    }
-
     /**
      * Set the requestId and serviceInstanceId
-     * 
+     *
      * @param reqId
      *            The requestId
      * @param svcId
@@ -1107,36 +1047,6 @@ public class MsoLogger {
         }
     }
 
-    /**
-     * Set the remoteIp and the basic HTTP Authentication user
-     * 
-     * @param remoteIpp
-     *            The remote ip address
-     * @param userp
-     *            The basic http authencitation user
-     */
-    public static void setLoggerParameters(String remoteIpp, String userp) {
-        if (null != remoteIpp) {
-            MDC.put(REMOTE_HOST, remoteIpp);
-        }
-        if (null != userp) {
-            MDC.put(USER, userp);
-        }
-    }
-
-    /**
-     * Set the serviceName
-     * 
-     * @param serviceNamep
-     *            The service name
-     */
-    public static void setServiceName(String serviceNamep) {
-        if (null != serviceNamep) {
-            MDC.put(SERVICE_NAME, serviceNamep);
-            MDC.remove(SERVICE_NAME_IS_METHOD_NAME);
-        }
-    }
-
     /**
      * Get the serviceName
      * 
@@ -1146,29 +1056,6 @@ public class MsoLogger {
         return MDC.get(SERVICE_NAME);
     }
 
-    /**
-     * Reset the serviceName
-     */
-    public static void resetServiceName() {
-        MDC.remove(SERVICE_NAME);
-    }
-
-    /**
-     * Set the requestId and serviceInstanceId based on the mso request
-     * 
-     * @param msoRequest
-     *            The mso request
-     */
-    public static void setLogContext(MsoRequest msoRequest) {
-        if (msoRequest != null) {
-            MDC.put(REQUEST_ID, msoRequest.getRequestId());
-            MDC.put(SERVICE_INSTANCE_ID, msoRequest.getServiceInstanceId());
-        } else {
-            MDC.put(REQUEST_ID, DUMMY_VALUE);
-            MDC.put(SERVICE_INSTANCE_ID, DUMMY_VALUE);
-        }
-    }
-
     private String normalize(String input) {
         if (input == null) {
             return null;
@@ -1211,14 +1098,4 @@ public class MsoLogger {
             defaultMetrics = MessageEnum.GENERAL_METRICS;
         }
     }
-
-       public void warnSimple(String message, Exception e) {
-               logger.warn(message,e);       
-               
-       }
-
-
-
-
-
 }