Merge "Issue #2142 fix cave logs of ufstatus messages on deployed systems" into development
Former-commit-id: 00301e81c6eb41278d9894633ce7f6050dcce1b8
This commit is contained in:
commit
f93cda10ec
14 changed files with 27 additions and 329 deletions
|
@ -24,7 +24,8 @@ Import-Package: com.raytheon.uf.common.python,
|
|||
com.raytheon.uf.common.time,
|
||||
com.raytheon.uf.viz.python.swt,
|
||||
com.raytheon.uf.viz.python.swt.widgets,
|
||||
org.apache.log4j
|
||||
org.apache.log4j,
|
||||
org.slf4j
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-BuddyPolicy: ext, registered, global
|
||||
Eclipse-RegisterBuddy: ch.qos.logback, org.apache.log4j
|
||||
Eclipse-RegisterBuddy: ch.qos.logback
|
||||
|
|
|
@ -19,13 +19,16 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.alertviz;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.statushandlers.AbstractStatusHandler;
|
||||
import org.eclipse.ui.statushandlers.StatusAdapter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
|
||||
import com.raytheon.uf.common.message.StatusMessage;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -42,7 +45,8 @@ import com.raytheon.uf.viz.core.status.VizStatusInternal;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 9, 2008 1433 chammack Initial creation
|
||||
* Sep 09, 2008 1433 chammack Initial creation
|
||||
* Aug 26, 2013 2142 njensen Changed to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -51,11 +55,13 @@ import com.raytheon.uf.viz.core.status.VizStatusInternal;
|
|||
|
||||
public class SystemStatusHandler extends AbstractStatusHandler {
|
||||
|
||||
private transient static final org.apache.log4j.Logger logger = Logger
|
||||
private transient static final Logger logger = LoggerFactory
|
||||
.getLogger("CaveLogger");
|
||||
|
||||
private static final String WORKSTATION = "WORKSTATION";
|
||||
|
||||
private static final Marker FATAL = MarkerFactory.getMarker("FATAL");
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -189,22 +195,23 @@ public class SystemStatusHandler extends AbstractStatusHandler {
|
|||
}
|
||||
|
||||
private void logStatus(StatusMessage status) {
|
||||
String msg = status.getDetails();
|
||||
switch (status.getPriority()) {
|
||||
case CRITICAL:
|
||||
logger.fatal(status);
|
||||
logger.error(FATAL, msg);
|
||||
break;
|
||||
case SIGNIFICANT:
|
||||
logger.error(status);
|
||||
logger.error(msg);
|
||||
break;
|
||||
case PROBLEM:
|
||||
logger.warn(status);
|
||||
logger.warn(msg);
|
||||
break;
|
||||
case EVENTA: // fall through
|
||||
case EVENTB:
|
||||
logger.info(status);
|
||||
logger.info(msg);
|
||||
break;
|
||||
case VERBOSE:
|
||||
logger.debug(status);
|
||||
logger.debug(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,11 +247,4 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.log4j"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
@ -41,11 +41,10 @@ Require-Bundle: org.eclipse.ui,
|
|||
com.raytheon.uf.common.alertmonitor;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.python;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.velocity;bundle-version="1.0.0",
|
||||
org.apache.log4j;bundle-version="1.0.0",
|
||||
ch.qos.logback;bundle-version="1.0.13"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-BuddyPolicy: ext, registered, global
|
||||
Eclipse-RegisterBuddy: org.apache.velocity, org.apache.log4j, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.comm, ch.qos.logback
|
||||
Eclipse-RegisterBuddy: org.apache.velocity, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.comm, ch.qos.logback
|
||||
Export-Package: com.raytheon.uf.viz.core,
|
||||
com.raytheon.uf.viz.core.alerts,
|
||||
com.raytheon.uf.viz.core.auth,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<appender name="CaveLogAppender" class="com.raytheon.uf.common.status.logback.EnvConfigurableRollingFileAppender">
|
||||
<!-- file and fileNamePattern will be overridden by the env variable if present, but are required by logback -->
|
||||
<file>cave-alertviz.log</file>
|
||||
<envLogVar>LOGFILE_CAVE</envLogVar>
|
||||
<rollingPolicy class="com.raytheon.uf.common.status.logback.EnvConfigurableFixedWindowRollingPolicy">
|
||||
<fileNamePattern>cave-alertviz.log%i</fileNamePattern>
|
||||
<envLogVar>LOGFILE_CAVE</envLogVar>
|
||||
|
@ -39,6 +40,7 @@
|
|||
<appender name="PerformanceLogAppender" class="com.raytheon.uf.common.status.logback.EnvConfigurableRollingFileAppender">
|
||||
<!-- file and fileNamePattern will be overridden by the env variable if present, but are required by logback -->
|
||||
<file>cave-performance.log</file>
|
||||
<envLogVar>LOGFILE_PERFORMANCE</envLogVar>
|
||||
<rollingPolicy class="com.raytheon.uf.common.status.logback.EnvConfigurableFixedWindowRollingPolicy">
|
||||
<fileNamePattern>cave-performance.log%i</fileNamePattern>
|
||||
<envLogVar>LOGFILE_PERFORMANCE</envLogVar>
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.core.log;
|
||||
|
||||
import org.apache.log4j.RollingFileAppender;
|
||||
import org.apache.log4j.helpers.LogLog;
|
||||
|
||||
/**
|
||||
* RollingFileAppender retrieves the value set for property EnvLogVar from the
|
||||
* system environment to define the log file.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 10, 2012 bgonzale Initial creation
|
||||
* Mar 21, 2013 1638 mschenke Moved from alertviz to core
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bgonzale
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EnvConfigurableRollingFileAppender extends RollingFileAppender {
|
||||
|
||||
private String envLogVar;
|
||||
|
||||
/**
|
||||
* @param envLogVar
|
||||
* the envLogVar to set
|
||||
*/
|
||||
public void setEnvLogVar(String envLogVar) {
|
||||
this.envLogVar = envLogVar;
|
||||
setFileFromEnv();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the envLogVar
|
||||
*/
|
||||
public String getEnvLogVar() {
|
||||
return envLogVar;
|
||||
}
|
||||
|
||||
private void setFileFromEnv() {
|
||||
if (envLogVar == null || envLogVar.isEmpty()) {
|
||||
LogLog.error("Appender [" + name
|
||||
+ "] requires EnvLogVar to be set.");
|
||||
} else {
|
||||
String file = System.getenv(envLogVar);
|
||||
|
||||
if (file == null || file.isEmpty()) {
|
||||
LogLog.error("Appender [" + name
|
||||
+ "] needs environment variable, " + envLogVar
|
||||
+ ", to be set.");
|
||||
} else {
|
||||
setFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
package com.raytheon.uf.viz.core.status;
|
||||
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import org.eclipse.core.internal.runtime.InternalPlatform;
|
||||
import org.eclipse.core.runtime.ILog;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Appender for the Eclipse status framework.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class EclipseILogAppender extends AppenderSkeleton {
|
||||
|
||||
private String pluginId;
|
||||
|
||||
private String category;
|
||||
|
||||
private String source;
|
||||
|
||||
private ILog log;
|
||||
|
||||
@Override
|
||||
protected void append(LoggingEvent arg0) {
|
||||
String pluginId = arg0.getLoggerName();
|
||||
Level level = arg0.getLevel();
|
||||
Throwable t = arg0.getThrowableInformation() == null ? null : arg0
|
||||
.getThrowableInformation().getThrowable();
|
||||
Priority priority = toPriority(level);
|
||||
UFStatus status = new UFStatus(priority, arg0.getRenderedMessage(), t);
|
||||
|
||||
getLog().log(new ILogStatus(status, category, source, pluginId));
|
||||
}
|
||||
|
||||
private ILog getLog() {
|
||||
if (log == null) {
|
||||
Bundle bundle = InternalPlatform.getDefault().getBundle(pluginId);
|
||||
log = InternalPlatform.getDefault().getLog(bundle);
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform log4j logging level to iStatus logging level.
|
||||
*
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private static Priority toPriority(Level level) {
|
||||
switch (level.toInt()) {
|
||||
case Level.TRACE_INT:
|
||||
return Priority.VERBOSE;
|
||||
case Level.DEBUG_INT:
|
||||
return Priority.DEBUG;
|
||||
case Level.INFO_INT:
|
||||
return Priority.INFO;
|
||||
case Level.WARN_INT:
|
||||
return Priority.WARN;
|
||||
case Level.ERROR_INT:
|
||||
return Priority.ERROR;
|
||||
case Level.FATAL_INT:
|
||||
return Priority.FATAL;
|
||||
default:
|
||||
return Priority.INFO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pluginId
|
||||
*/
|
||||
public String getPluginId() {
|
||||
return pluginId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pluginId
|
||||
* the pluginId to set
|
||||
*/
|
||||
public void setPluginId(String pluginId) {
|
||||
this.pluginId = pluginId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the category
|
||||
*/
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param category
|
||||
* the category to set
|
||||
*/
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the source
|
||||
*/
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param source
|
||||
* the source to set
|
||||
*/
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
private static class ILogStatus extends VizStatusInternal {
|
||||
public ILogStatus(UFStatus status, String category, String source,
|
||||
String pluginName) {
|
||||
super(status, category, source, pluginName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -470,13 +470,6 @@
|
|||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.log4j"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.derby"
|
||||
download-size="0"
|
||||
|
|
|
@ -4,8 +4,7 @@ Bundle-Name: Pgen Plug-in
|
|||
Bundle-SymbolicName: gov.noaa.nws.ncep.ui.pgen;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: gov.noaa.nws.ncep.ui.pgen.Activator
|
||||
Eclipse-RegisterBuddy: com.raytheon.viz.core,
|
||||
org.apache.log4j
|
||||
Eclipse-RegisterBuddy: com.raytheon.viz.core
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.geotools,
|
||||
|
|
|
@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.ui,
|
|||
gov.noaa.nws.ncep.edex.common;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.viz.localization;bundle-version="1.0.0",
|
||||
org.geotools,
|
||||
org.apache.log4j;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.gempak.parameters.core;bundle-version="1.0.0"
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: gov.noaa.nws.ncep.viz.common,
|
||||
|
@ -30,5 +29,6 @@ Export-Package: gov.noaa.nws.ncep.viz.common,
|
|||
gov.noaa.nws.ncep.viz.common.ui.color
|
||||
Import-Package: com.raytheon.uf.common.comm,
|
||||
com.vividsolutions.jts.geom,
|
||||
javax.measure.unit
|
||||
javax.measure.unit,
|
||||
org.apache.log4j
|
||||
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package gov.noaa.nws.ncep.viz.common;
|
||||
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import org.eclipse.core.runtime.ILog;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
public class Log4jToILog {
|
||||
|
||||
/**
|
||||
* This method adds an appender to the log4j root logger, which writes
|
||||
* log4j logging statements to Eclipse logging framework. All the messages
|
||||
* will be redirected and finally appear in the alertviz bar.
|
||||
*
|
||||
* @param log
|
||||
* @param PLUGIN_ID
|
||||
*/
|
||||
public static void setup(final ILog log, final String PLUGIN_ID) {
|
||||
|
||||
Logger.getRootLogger().addAppender(new AppenderSkeleton() {
|
||||
|
||||
@Override
|
||||
protected void append(LoggingEvent arg0) {
|
||||
Level level = arg0.getLevel();
|
||||
|
||||
Throwable t = arg0.getThrowableInformation() == null ? null : arg0
|
||||
.getThrowableInformation().getThrowable();
|
||||
if (t == null) {
|
||||
log.log(new Status(toIStatusLevel(level), PLUGIN_ID, arg0.getRenderedMessage()));
|
||||
} else {
|
||||
log.log(new Status(toIStatusLevel(level), PLUGIN_ID, arg0.getRenderedMessage(), t));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform log4j logging level to iStatus logging level.
|
||||
*
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private static int toIStatusLevel(Level level) {
|
||||
int istatus;
|
||||
switch (level.toInt()) {
|
||||
case Level.TRACE_INT:
|
||||
istatus = IStatus.OK;
|
||||
break;
|
||||
case Level.DEBUG_INT:
|
||||
istatus = IStatus.OK;
|
||||
break;
|
||||
case Level.INFO_INT:
|
||||
istatus = IStatus.INFO;
|
||||
break;
|
||||
case Level.WARN_INT:
|
||||
istatus = IStatus.WARNING;
|
||||
break;
|
||||
case Level.ERROR_INT:
|
||||
istatus = IStatus.ERROR;
|
||||
break;
|
||||
case Level.FATAL_INT:
|
||||
istatus = IStatus.ERROR;
|
||||
break;
|
||||
default:
|
||||
istatus = IStatus.OK;
|
||||
}
|
||||
return istatus;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
com.raytheon.viz.core;bundle-version="1.11.31",
|
||||
com.raytheon.viz.ui;bundle-version="1.12.1174"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-RegisterBuddy: org.apache.log4j, gov.noaa.nws.ncep.resources, com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.uf.common.serialization
|
||||
Eclipse-RegisterBuddy: gov.noaa.nws.ncep.resources, com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.uf.common.serialization
|
||||
Eclipse-BuddyPolicy: ext, global
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Export-Package: gov.noaa.nws.ncep.viz.rsc.ffa.rsc,
|
||||
|
|
|
@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
com.raytheon.uf.edex.decodertools,
|
||||
gov.noaa.nws.ncep.common.dataplugin.aww;bundle-version="1.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-RegisterBuddy: org.apache.log4j, gov.noaa.nws.ncep.resources, com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.uf.common.serialization
|
||||
Eclipse-RegisterBuddy: gov.noaa.nws.ncep.resources, com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.uf.common.serialization
|
||||
Eclipse-BuddyPolicy: ext, global
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: gov.noaa.nws.ncep.common.log.logger
|
||||
|
|
|
@ -5,7 +5,7 @@ Bundle-SymbolicName: gov.noaa.nws.ncep.viz.tools;singleton:=true
|
|||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: gov.noaa.nws.ncep.viz.tools.Activator
|
||||
Eclipse-BuddyPolicy: registered, ext, global
|
||||
Eclipse-RegisterBuddy: org.apache.log4j, com.raytheon.viz.core, com.raytheon.uf.common.serialization
|
||||
Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.uf.common.serialization
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.geotools;bundle-version="2.5.2",
|
||||
|
|
Loading…
Add table
Reference in a new issue