[slf4j-dev] SLF4J Wrapper class line number incorrect

Ashley Westwell ashley.westwell at netoffice.ca
Fri Feb 27 02:49:41 CET 2009


Hey Ralph  
   
Took a look at the call and the wrapper class. My issue I dont want to esxpose the methods defined in the Logger interface. I only want to expose my methods for logging. Thats why I did not implement the Logger interface. Can you suggest how I could deal with the line number issue with out implementing Logger?  
   
Thanks
      _____  

  From: Ralph Goers [mailto:rgoers at apache.org]
To: slf4j developers list [mailto:dev at slf4j.org]
Sent: Fri, 20 Feb 2009 17:44:38 -0500
Subject: Re: [slf4j-dev] SLF4J Wrapper class line number incorrect

  
  
Take a look at XLogger in slf4j-ext.  

  
Out of curiosity, what do you need the wrapper for?  

Ralph  

  
On Feb 20, 2009, at 2:58 PM, Ashley Westwell wrote:
    
  
Good Afternoon

I have created a wrapper layer for SLF4J (Listed below). However the line number are incorrect, it is using the line numbers in the wrapper class not the class that I called the wrapper from. What is the correct way to fix this?

package com.test.commons.logging;

import com.test.commons.logging.LoggerFactory.LEVEL;

public class Logger {

    private LEVEL infoLevel = LEVEL.FINE;
    private LEVEL debugLevel = LEVEL.FINE;
    
    private org.slf4j.Logger logger = null;

    public Logger(Class clazz, LEVEL infoLevel, LEVEL debugLevel) {
        this.infoLevel = infoLevel;
        this.debugLevel = debugLevel;
        logger = org.slf4j.LoggerFactory.getLogger(clazz);
        
    }
    
    public Logger(String name, LEVEL infoLevel, LEVEL debugLevel) {
        this.infoLevel = infoLevel;
        this.debugLevel = debugLevel;
        logger = org.slf4j.LoggerFactory.getLogger(name);
    }
    
    public void info(String message) {
        logger.info(message);
    }
    
    public void info(String message, Throwable throwable) {
        logger.info(message, throwable);
    }
    
    public void info(String message, Object[] objects) {
        if(logger.isInfoEnabled()) {
            logger.info(message, objects);
        }
    }
    
    public void info(LEVEL level, String message) {
        if((logger.isInfoEnabled()) && (level.ordinal() <= infoLevel.ordinal())) {
            logger.info(message);
        }
    }
    
    public void info(LEVEL level, String message, Throwable throwable) {
        if((logger.isInfoEnabled()) && (level.ordinal() <= infoLevel.ordinal())) {
            logger.info(message, throwable);
        }
    }
    
    public void info(LEVEL level, String message, Object[] objects) {
        if((logger.isInfoEnabled()) && (level.ordinal() <= infoLevel.ordinal())) {
            logger.info(message, objects);
        }
    }
    
    // Debug messages.
    public void debug(String message) {
        if(logger.isDebugEnabled()) {
            logger.debug(message);
        }
        
    }
    public void debug(String message, Throwable throwable) {
        if(logger.isDebugEnabled()) {
            logger.debug(message, throwable);
        }
    }
    
    public void debug(String message, Object[] objects) {
        if(logger.isDebugEnabled()) {
            logger.debug(message, objects);
        }
    }
    
    public void debug(LEVEL level, String message) {
        if((logger.isDebugEnabled()) && (level.ordinal() <= debugLevel.ordinal())) {
                logger.debug(message);
        }
    }
    
    public void debug(LEVEL level, String message, Throwable throwable) {
        if((logger.isDebugEnabled()) && (level.ordinal() <= debugLevel.ordinal())) {
            logger.debug(message, throwable);
        }
    }

    public void debug(LEVEL level, String message, Object[] objects) {
        if((logger.isDebugEnabled()) && (level.ordinal() <= debugLevel.ordinal())) {
            logger.debug(message, objects);
        }
    }
    
    // The highest value; intended for extremely important messages (e.g. fatal program errors).
    public void severe(String message) {
        if(logger.isErrorEnabled()) {
            logger.error(message);
        }
    }
    
    public void severe(String message, Throwable throwable) {
        if(logger.isErrorEnabled()) {
            logger.error(message, throwable);
        }
    }
    
    public void severe(String message, Object[] objects) {
        if(logger.isErrorEnabled()) {
            logger.error(message, objects);
        }
    }
    
    // Intended for warning messages.
    public void warning(String message) {
        if(logger.isWarnEnabled()) {
            logger.warn(message);
        }
    }
    
    public void warning(String message, Throwable throwable) {
        if(logger.isWarnEnabled()) {
            logger.warn(message, throwable);
        }
    }
    
    public void warning(String message, Object[] objects) {
        if(logger.isWarnEnabled()) {
            logger.warn(message, objects);
        }
    }
    
}

    _____  

  
Notice: This email is confidential.  If you are not the intended recipient, please notify the sender by return email and delete this message from your mail box without reading or copying it or any attachments.

Attention: Ce courriel est confidentiel. Si vous n'êtes pas le destinataire prévu, veuillez en informer l'expéditeur par le courriel de retour et le supprimer immédiatement sans le lire ou le copier (incluant les pièces jointes,  le cas échéant).
_______________________________________________
dev mailing list
dev at slf4j.org
http://www.slf4j.org/mailman/listinfo/dev
      
   
 



Notice: This email is confidential.  If you are not the intended recipient, please notify the sender by return email and delete this message from your mail box without reading or copying it or any attachments.

Attention: Ce courriel est confidentiel. Si vous n'êtes pas le destinataire prévu, veuillez en informer l'expéditeur par le courriel de retour et le supprimer immédiatement sans le lire ou le copier (incluant les pièces jointes,  le cas échéant).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/slf4j-dev/attachments/20090226/750bc227/attachment.htm>


More information about the slf4j-dev mailing list