| 1 | /* |
| 2 | Copyright (C) 2006 MySQL AB |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of version 2 of the GNU General Public License as |
| 6 | published by the Free Software Foundation. |
| 7 | |
| 8 | There are special exceptions to the terms and conditions of the GPL |
| 9 | as it is applied to this software. View the full text of the |
| 10 | exception in file EXCEPTIONS-CONNECTOR-J in the directory of this |
| 11 | software distribution. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | |
| 22 | */ |
| 23 | |
| 24 | package com.mysql.jdbc.log; |
| 25 | |
| 26 | import org.apache.commons.logging.Log; |
| 27 | import org.apache.commons.logging.LogFactory; |
| 28 | |
| 29 | public class CommonsLogger implements com.mysql.jdbc.log.Log { |
| 30 | private Log logger; |
| 31 | |
| 32 | public CommonsLogger(String instanceName) { |
| 33 | logger = LogFactory.getLog(instanceName); |
| 34 | } |
| 35 | |
| 36 | public boolean isDebugEnabled() { |
| 37 | return this.logger.isInfoEnabled(); |
| 38 | } |
| 39 | |
| 40 | public boolean isErrorEnabled() { |
| 41 | return this.logger.isErrorEnabled(); |
| 42 | } |
| 43 | |
| 44 | public boolean isFatalEnabled() { |
| 45 | return this.logger.isFatalEnabled(); |
| 46 | } |
| 47 | |
| 48 | public boolean isInfoEnabled() { |
| 49 | return this.logger.isInfoEnabled(); |
| 50 | } |
| 51 | |
| 52 | public boolean isTraceEnabled() { |
| 53 | return this.logger.isTraceEnabled(); |
| 54 | } |
| 55 | |
| 56 | public boolean isWarnEnabled() { |
| 57 | return this.logger.isWarnEnabled(); |
| 58 | } |
| 59 | |
| 60 | public void logDebug(Object msg) { |
| 61 | this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg)); |
| 62 | } |
| 63 | |
| 64 | public void logDebug(Object msg, Throwable thrown) { |
| 65 | this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg), thrown); |
| 66 | } |
| 67 | |
| 68 | public void logError(Object msg) { |
| 69 | this.logger.error(LogUtils.expandProfilerEventIfNecessary(msg)); |
| 70 | } |
| 71 | |
| 72 | public void logError(Object msg, Throwable thrown) { |
| 73 | this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg), thrown); |
| 74 | } |
| 75 | |
| 76 | public void logFatal(Object msg) { |
| 77 | this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg)); |
| 78 | } |
| 79 | |
| 80 | public void logFatal(Object msg, Throwable thrown) { |
| 81 | this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg), thrown); |
| 82 | } |
| 83 | |
| 84 | public void logInfo(Object msg) { |
| 85 | this.logger.info(LogUtils.expandProfilerEventIfNecessary(msg)); |
| 86 | } |
| 87 | |
| 88 | public void logInfo(Object msg, Throwable thrown) { |
| 89 | this.logger.info(LogUtils.expandProfilerEventIfNecessary(msg), thrown); |
| 90 | } |
| 91 | |
| 92 | public void logTrace(Object msg) { |
| 93 | this.logger.trace(LogUtils.expandProfilerEventIfNecessary(msg)); |
| 94 | } |
| 95 | |
| 96 | public void logTrace(Object msg, Throwable thrown) { |
| 97 | this.logger.trace(LogUtils.expandProfilerEventIfNecessary(msg), thrown); |
| 98 | } |
| 99 | |
| 100 | public void logWarn(Object msg) { |
| 101 | this.logger.warn(LogUtils.expandProfilerEventIfNecessary(msg)); |
| 102 | } |
| 103 | |
| 104 | public void logWarn(Object msg, Throwable thrown) { |
| 105 | this.logger.warn(LogUtils.expandProfilerEventIfNecessary(msg), thrown); |
| 106 | } |
| 107 | |
| 108 | } |