001/*
002 * HA-JDBC: High-Availability JDBC
003 * Copyright (C) 2012  Paul Ferraro
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Lesser General Public License as published by
007 * the Free Software Foundation, either version 3 of the License, or
008 * (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018package net.sf.hajdbc.logging.jboss;
019
020import java.util.EnumMap;
021import java.util.Map;
022
023import org.jboss.logging.Logger;
024
025import net.sf.hajdbc.logging.AbstractLogger;
026import net.sf.hajdbc.logging.Level;
027
028/**
029 * @author Paul Ferraro
030 */
031public class JBossLogger extends AbstractLogger
032{
033        private static final Map<Level, org.jboss.logging.Logger.Level> levels = new EnumMap<Level, org.jboss.logging.Logger.Level>(Level.class);
034        static
035        {
036                levels.put(Level.ERROR, org.jboss.logging.Logger.Level.ERROR);
037                levels.put(Level.WARN, org.jboss.logging.Logger.Level.WARN);
038                levels.put(Level.INFO, org.jboss.logging.Logger.Level.INFO);
039                levels.put(Level.DEBUG, org.jboss.logging.Logger.Level.DEBUG);
040                levels.put(Level.TRACE, org.jboss.logging.Logger.Level.TRACE);
041        }
042        
043        private final Logger logger;
044        
045        public JBossLogger(Class<?> targetClass)
046        {
047                this.logger = Logger.getLogger(targetClass);
048        }
049        
050        /**
051         * {@inheritDoc}
052         * @see net.sf.hajdbc.logging.Logger#log(net.sf.hajdbc.logging.Level, java.lang.Throwable, java.lang.String, java.lang.Object[])
053         */
054        @Override
055        public void log(Level level, Throwable e, String pattern, Object... args)
056        {
057                this.logger.logv(levels.get(level), e, pattern, args);
058        }
059}