JackieJ / proxy-vole

Automatically exported from code.google.com/p/proxy-vole
0 stars 1 forks source link

Use slf4j rather then home cooked logging #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Just started using proxy-vole, its great thanks!

I know this is kind of an annoying suggestion, and you are probably using the 
home cooked logging to minimize dependencies.  That said,plugging into 
somethign many people are using anyway would be awesome :)  

thanks again!

Original issue reported on code.google.com by ryan...@gmail.com on 19 Jul 2010 at 9:00

GoogleCodeExporter commented 8 years ago
Here is simple code to make things work with slf4j

      com.btr.proxy.util.Logger.setBackend( new com.btr.proxy.util.Logger.LogBackEnd() {

        @Override
        public boolean isLogginEnabled(LogLevel level) {          
          switch( level ) {
          case INFO:    return log.isInfoEnabled();
          case DEBUG:   return log.isDebugEnabled();
          case ERROR:   return log.isErrorEnabled();
          case TRACE:   return log.isTraceEnabled();
          case WARNING: return log.isWarnEnabled();
          }
          return false;
        }

        @Override
        public void log(Class<?> clazz, LogLevel level, String msg, Object ... params ) {
          msg = msg.replace( "{0}", "{}" ).replace( "{1}", "{}" );
          switch( level ) {
          case INFO:    log.info( msg, params ); break;
          case DEBUG:   log.debug( msg, params ); break;
          case ERROR:   log.error( msg, params ); break;
          case TRACE:   log.trace( msg, params ); break;
          case WARNING: log.warn( msg, params ); break;
          }
        }
      });

Original comment by ryan...@gmail.com on 19 Jul 2010 at 9:39

GoogleCodeExporter commented 8 years ago
Hello ryantxu

I'm aware of slf4j and use it internally for all my projects. But I made the 
decision to have only minimum external dependencies to make it straight forward 
to add proxy-vole to any project. Yes many projects are using slf4j but also 
many use log4j or java logging and they would have to include another logging 
api (slf4j) and then use an adapter.  

My intention is that if someone really needs logging in proxy-vole then he can 
write a simple adapter for his preferred logging API with only a view lines of 
code as you can see in your example.

Thank you a lot for your input and for your example code. I think other people 
can use that as starting point if they have a similar need but I will not 
include it into the offical release to make sure that proxy-vole stays light 
weight.

Have fun,
- Rossi

Original comment by rosstaus...@googlemail.com on 21 Jul 2010 at 7:24