Example usage for org.apache.commons.logging Log isWarnEnabled

List of usage examples for org.apache.commons.logging Log isWarnEnabled

Introduction

In this page you can find the example usage for org.apache.commons.logging Log isWarnEnabled.

Prototype

boolean isWarnEnabled();

Source Link

Document

Is warn logging currently enabled?

Usage

From source file:LoggingTrial.java

public static void main(String[] args) {
    Log log = LogFactory.getLog(LoggingTrial.class);
    System.out.println("The Log being used >>> " + log);

    Exception e = new Exception("A DUMMY EXCEPTION");
    if (log.isTraceEnabled()) {
        log.trace("TRACE TEST");
        log.trace("TRACE TEST", e);
    }/*from w  w  w .  ja  va2s .  co  m*/
    if (log.isDebugEnabled()) {
        log.debug("DEBUG TEST");
        log.debug("DEBUG TEST", e);
    }

    if (log.isInfoEnabled()) {
        log.info("INFO TEST");
        log.info("INFO TEST", e);
    }
    if (log.isWarnEnabled()) {
        log.warn("WARN TEST");
        log.warn("WARN TEST", e);
    }

    if (log.isErrorEnabled()) {
        log.error("ERROR TEST");
        log.error("ERROR TEST", e);
    }

    if (log.isFatalEnabled()) {
        log.fatal("FATAL TEST");
        log.fatal("FATAL TEST", e);
    }
}

From source file:com.headissue.pigeon.util.LogUtils.java

public static void warn(Log log, String message, Object... args) {
    if (log.isWarnEnabled()) {
        if (args != null && args.length > 0) {
            message = String.format(message, args);
        }//from  w w w  .  j  a  va 2  s .  c om
        log.warn(message);
    }
}

From source file:com.headissue.pigeon.util.LogUtils.java

public static void warn(Log log, Throwable t, String message, Object... args) {
    if (log.isWarnEnabled()) {
        if (args != null && args.length > 0) {
            message = String.format(message, args);
        }//w w w  . j av  a2s  . c o m
        log.warn(message, t);
    }
}

From source file:net.sf.nmedit.jtheme.JTCursor.java

private static Cursor createCursor(int id) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    URL res = getResource(id);//from w  ww .j av a 2 s . c  o m

    if (res == null) {
        Log log = LogFactory.getLog(JTCursor.class);
        if (log.isWarnEnabled()) {
            log.warn("Could not find cursor: id=" + id + ", url=" + res);
        }
        return Cursor.getDefaultCursor();
    }

    Image img;
    try {
        img = ImageIO.read(res);
    } catch (IOException e) {
        Log log = LogFactory.getLog(JTCursor.class);
        if (log.isWarnEnabled()) {
            log.warn("Could not find cursor: id=" + id + ", url=" + res, e);
        }
        return Cursor.getDefaultCursor();
    }

    return tk.createCustomCursor(img, new Point(4, 16), names[id]);
}

From source file:com.rsmart.rfabric.logging.FormattedLogger.java

/**
 * Wraps {@link Log#warn(String)}/*from   w  w w . jav  a  2 s.co 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(String pattern, Object... objs) {
    Log log = getLog();
    if (log.isWarnEnabled()) {
        log.warn(getMessage(pattern, objs));
    }
}

From source file:com.buffalokiwi.api.APILog.java

/**
 * Log a message with warn log level./*ww w .  java  2 s  .  c  o m*/
 *
 * @param log Log to write to
 * @param message log this message
 */
public static void warn(final Log log, final Object... message) {
    if (log.isWarnEnabled())
        log.warn(concat(message));
}

From source file:com.buffalokiwi.api.APILog.java

/**
 * Log an error with warn log level.//from   www.ja v a  2s. c om
 *
 * @param log Log to write to
 * @param message log this message
 * @param t log this cause
 */
public static void warn(final Log log, final Throwable t, final Object... message) {
    if (log.isWarnEnabled())
        log.warn(concat(message), t);
}

From source file:com.stimulus.archiva.exception.ChainedException.java

public static Level getLoggingLevel(Log logger) {
    if (logger.isDebugEnabled())
        return Level.DEBUG;
    else if (logger.isInfoEnabled())
        return Level.INFO;
    else if (logger.isWarnEnabled())
        return Level.WARN;
    else if (logger.isErrorEnabled())
        return Level.ERROR;
    else if (logger.isFatalEnabled())
        return Level.FATAL;

    return Level.DEBUG;
}

From source file:net.sf.nmedit.jtheme.image.SVGImageResource.java

private static Image renderSVGImage(Reader source, int width, int height) {

    ImageTranscoder pngt = new PNGTranscoder();
    TranscoderInput input = new TranscoderInput(source);

    ByteArrayOutputStream out = new ByteArrayOutputStream(8096);

    try {// w w  w  .  j a  v a2s .  co m
        TranscoderOutput output = new TranscoderOutput(out);

        if (width > 0 && height > 0) {
            Float w = new Float(width);

            pngt.addTranscodingHint(PNGTranscoder.KEY_WIDTH, w);
            pngt.addTranscodingHint(PNGTranscoder.KEY_MAX_WIDTH, w);
            Float h = new Float(height);
            pngt.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, h);
            pngt.addTranscodingHint(PNGTranscoder.KEY_MAX_HEIGHT, h);
        }

        // TODO other solution for SAX parser / class loader issue ?
        Thread.currentThread().setContextClassLoader(ImageResource.class.getClassLoader());

        // Save the image.
        try {
            pngt.transcode(input, output);
        } catch (TranscoderException e) {
            Log log = LogFactory.getLog(ImageResource.class);
            if (log.isWarnEnabled()) {
                log.warn("could not render image", e);
            }
            return null;
        }
    } finally {
        try {
            source.close();
        } catch (IOException e) {
            Log log = LogFactory.getLog(ImageResource.class);
            if (log.isWarnEnabled()) {
                log.warn("could not close stream", e);
            }
        }
    }

    return Toolkit.getDefaultToolkit().createImage(out.toByteArray());

}

From source file:net.sf.nmedit.jtheme.store2.ImageElement.java

public static String element2txt(Element el) {
    TransformerFactory tf = TransformerFactory.newInstance();
    // set all necessary features for your transformer -> see OutputKeys
    Transformer t;//from  www  .j a  va  2s.  c om
    try {
        t = tf.newTransformer();
    } catch (TransformerConfigurationException e) {
        return null;
    }

    StringWriter sw = new StringWriter();
    try {
        t.transform(new JDOMSource(el), new StreamResult(sw));
    } catch (TransformerException e) {
        Log log = getLogger();
        if (log.isWarnEnabled()) {
            log.warn("element2txt failed", e);
        }
        return null;
    }

    return sw.toString();
}