List of usage examples for org.apache.commons.logging Log isWarnEnabled
boolean isWarnEnabled();
From source file:org.eclipse.smila.search.utils.indexstructure.IndexStructureAccess.java
public static IndexStructureAccess getInstance() { final Log log = LogFactory.getLog(IndexStructureAccess.class); IndexStructureAccess[] types;// w w w . j a va2 s . co m try { types = getTypes(); if (types.length != 1) { if (log.isWarnEnabled()) { log.warn("invalid index structure access count [" + types.length + "]"); } return null; } return types[0]; } catch (final ISException e) { if (log.isErrorEnabled()) { log.error(e); } return null; } }
From source file:org.eclipse.smila.search.utils.search.SearchAccess.java
public static SearchAccess getInstance() { final Log log = LogFactory.getLog(SearchAccess.class); SearchAccess[] types;/*from w w w. java 2 s .co m*/ try { types = getTypes(); if (types.length != 1) { if (log.isWarnEnabled()) { log.warn("invalid index structure access count [" + types.length + "]"); } return null; } return types[0]; } catch (final DSearchException e) { if (log.isErrorEnabled()) { log.error(e); } return null; } }
From source file:org.elasticsearch.client.RequestLogger.java
/** * Logs a request that yielded a response *//*from w w w. j a va 2s . c om*/ static void logResponse(Log logger, HttpUriRequest request, HttpHost host, HttpResponse httpResponse) { if (logger.isDebugEnabled()) { logger.debug("request [" + request.getMethod() + " " + host + getUri(request.getRequestLine()) + "] returned [" + httpResponse.getStatusLine() + "]"); } if (logger.isWarnEnabled()) { Header[] warnings = httpResponse.getHeaders("Warning"); if (warnings != null && warnings.length > 0) { logger.warn(buildWarningMessage(request, host, warnings)); } } if (tracer.isTraceEnabled()) { String requestLine; try { requestLine = buildTraceRequest(request, host); } catch (IOException e) { requestLine = ""; tracer.trace("error while reading request for trace purposes", e); } String responseLine; try { responseLine = buildTraceResponse(httpResponse); } catch (IOException e) { responseLine = ""; tracer.trace("error while reading response for trace purposes", e); } tracer.trace(requestLine + '\n' + responseLine); } }
From source file:org.inwiss.platform.common.util.ConvertUtil.java
/** * Converts string to byte array according to specified encoding * * @param content String to convert to array * @param encoding Encoding string, if <code>null</code> default is used * @return byte array/*from w ww .jav a2s . c o m*/ */ public static byte[] convertToByteArray(String content, String encoding) { Log log = LogFactory.getLog(ConvertUtil.class); if (content == null) { return null; } if (encoding == null) { encoding = Constants.DEFAULT_ENCODING; } if (log.isDebugEnabled()) { log.debug("Converting to byte array using: " + encoding); } byte[] value; try { value = content.getBytes(encoding); } catch (UnsupportedEncodingException ex) { if (log.isWarnEnabled()) { log.warn(ex); } return content.getBytes(); } return value; }
From source file:org.jboss.netty.logging.CommonsLoggerTest.java
@Test public void testIsWarnEnabled() { org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class); expect(mock.isWarnEnabled()).andReturn(true); replay(mock);// w ww. j a va 2 s. c o m InternalLogger logger = new CommonsLogger(mock, "foo"); assertTrue(logger.isWarnEnabled()); verify(mock); }
From source file:org.jboss.set.aphrodite.common.Utils.java
public static void logWarnMessage(Log log, String message) { if (log.isWarnEnabled()) log.warn(message); }
From source file:org.kuali.kra.logging.BufferedLogger.java
/** * Wraps {@link Log#warn(String)}//from ww w.j a va 2s . c o m * * @param pattern to format against * @param objs an array of objects used as parameters to the <code>pattern</code> */ public static final void warn(Object... objs) { Log log = getLogger(); if (log.isWarnEnabled()) { log.warn(getMessage(objs)); } }
From source file:org.mule.api.processor.LoggerMessageProcessorTestCase.java
private Log buildMockLogger() { Log mockLogger = mock(Log.class); doNothing().when(mockLogger).error(any()); doNothing().when(mockLogger).warn(any()); doNothing().when(mockLogger).info(any()); doNothing().when(mockLogger).debug(any()); doNothing().when(mockLogger).trace(any()); // All levels enabled by default when(mockLogger.isErrorEnabled()).thenReturn(true); when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockLogger.isInfoEnabled()).thenReturn(true); when(mockLogger.isDebugEnabled()).thenReturn(true); when(mockLogger.isTraceEnabled()).thenReturn(true); return mockLogger; }
From source file:org.pentaho.reporting.platform.plugin.ReportContentUtil.java
/** * Apply inputs (if any) to corresponding report parameters, care is taken when * checking parameter types to perform any necessary casting and conversion. * * @param report The report to retrieve parameter definitions and values from. * @param context a ParameterContext for which the parameters will be under * @param validationResult the validation result that will hold the warnings. If null, a new one will be created. * @return the validation result containing any parameter validation errors. * @throws java.io.IOException if the report of this component could not be parsed. * @throws ResourceException if the report of this component could not be parsed. *//*from w ww . j av a 2s . com*/ public static ValidationResult applyInputsToReportParameters(final MasterReport report, final ParameterContext context, final Map<String, Object> inputs, ValidationResult validationResult) throws IOException, ResourceException { if (validationResult == null) { validationResult = new ValidationResult(); } // apply inputs to report if (inputs != null) { final Log log = LogFactory.getLog(SimpleReportingComponent.class); final ParameterDefinitionEntry[] params = report.getParameterDefinition().getParameterDefinitions(); final ReportParameterValues parameterValues = report.getParameterValues(); for (final ParameterDefinitionEntry param : params) { final String paramName = param.getName(); try { final Object computedParameter = ReportContentUtil.computeParameterValue(context, param, inputs.get(paramName)); parameterValues.put(param.getName(), computedParameter); if (log.isInfoEnabled()) { log.info(Messages.getInstance().getString("ReportPlugin.infoParameterValues", //$NON-NLS-1$ paramName, String.valueOf(inputs.get(paramName)), String.valueOf(computedParameter))); } } catch (Exception e) { if (log.isWarnEnabled()) { log.warn(Messages.getInstance().getString("ReportPlugin.logErrorParametrization"), e); //$NON-NLS-1$ } validationResult.addError(paramName, new ValidationMessage(e.getMessage())); } } } return validationResult; }
From source file:org.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java
/** {@inheritDoc} **/ public <T> void instantiationFailed(final PicoContainer container, final ComponentAdapter<T> componentAdapter, final Constructor<T> constructor, final Exception cause) { Log log = getLog(constructor); if (log.isWarnEnabled()) { log.warn(ComponentMonitorHelper.format(ComponentMonitorHelper.INSTANTIATION_FAILED, ctorToString(constructor), cause.getMessage()), cause); }/* www . j av a2 s .co m*/ delegate.instantiationFailed(container, componentAdapter, constructor, cause); }