apache-poi/src/java/org/apache/poi/util/CommonsLogger.java
Ugo Cei 68f4aa5fbc Merged revisions 615190-618235 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk

........
  r615190 | nick | 2008-01-25 12:52:39 +0100 (Fri, 25 Jan 2008) | 1 line
  
  Correctly handle the last paragraph via a fix to TableCell - patch from bug #44292
........
  r615255 | nick | 2008-01-25 17:15:49 +0100 (Fri, 25 Jan 2008) | 1 line
  
  Don't swap AreaPtg references from relative to absolute, by correctly processing the fields. Patch from bug #44293
........
  r615259 | nick | 2008-01-25 17:33:59 +0100 (Fri, 25 Jan 2008) | 1 line
  
  Add a test to show the bug #42618 appears to be incorrect
........
  r615310 | yegor | 2008-01-25 20:27:56 +0100 (Fri, 25 Jan 2008) | 1 line
  
  commented failing test42618()
........
  r615315 | yegor | 2008-01-25 20:37:22 +0100 (Fri, 25 Jan 2008) | 1 line
  
  fix bug #44296: HSLF Not Extracting Slide Background Image
........
  r615610 | yegor | 2008-01-27 15:55:32 +0100 (Sun, 27 Jan 2008) | 1 line
  
  fix bug #44297: IntPtg must operate with unsigned short. Reading signed short results in incorrect formula calculation.
........
  r615769 | yegor | 2008-01-28 09:53:19 +0100 (Mon, 28 Jan 2008) | 1 line
  
  start a new POI 3.1 section in the change log
........
  r615859 | nick | 2008-01-28 13:18:12 +0100 (Mon, 28 Jan 2008) | 1 line
  
  Mostly fix bug 42618 (really this time...) - can now open the file properly, but getCellFormula() is still playing up (bug #44306 opened for this)
........
  r617156 | nick | 2008-01-31 17:41:53 +0100 (Thu, 31 Jan 2008) | 1 line
  
  Lots of documentation updates, to make it clearer how the code actually works
........
  r617167 | nick | 2008-01-31 18:30:16 +0100 (Thu, 31 Jan 2008) | 1 line
  
  Convert HSSFEventFactory to using the new HSSFRecordStream, which returns fully-formed HSSFRecords. HSSFRecordStream allows for pull-style eventusermodel processing
........
  r617483 | nick | 2008-02-01 13:13:08 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Tweak the javadoc so it's clearer on the overview what the getFormat method does
........
  r617487 | nick | 2008-02-01 13:29:38 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions - triggered by bug #44326
........
  r617491 | nick | 2008-02-01 14:02:06 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Patch from bug #44336 - correctly escape sheet names in formula references, including tests for this, and fixes to old tests that were expecting the un-escaped sheet names
........
  r617516 | nick | 2008-02-01 16:20:55 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Make a start on the hyperlink record support - not finished yet though, so not enabled
........
  r617523 | nick | 2008-02-01 16:41:32 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Get the Hyperlink record code so that it doesn't break any existing tests, and add in (no usermodel support yet though)
........
  r617555 | nick | 2008-02-01 17:52:58 +0100 (Fri, 01 Feb 2008) | 1 line
  
  More Hyperlink support. Doesn't end up in HSSFCell just yet, as the records are in the wrong bit of the file, so don't get associated with the sheet. All tests still passing though
........
  r617834 | yegor | 2008-02-02 18:06:14 +0100 (Sat, 02 Feb 2008) | 1 line
  
  usermodel support for excel hyperlinks
........
  r618230 | nick | 2008-02-04 11:48:29 +0100 (Mon, 04 Feb 2008) | 1 line
  
  Implement CountA, CountIf, Index, Rows and Columns functions. Patch from Josh Micich in bug #44345
........
  r618235 | nick | 2008-02-04 12:14:49 +0100 (Mon, 04 Feb 2008) | 1 line
  
  Test file with hyperlinks on many sheets, of different types
........


git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@618325 13f79535-47bb-0310-9956-ffa450edef68
2008-02-04 16:55:43 +00:00

224 lines
5.2 KiB
Java

/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A logger class that strives to make it as easy as possible for
* developers to write log calls, while simultaneously making those
* calls as cheap as possible by performing lazy evaluation of the log
* message.<p>
*
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/
public class CommonsLogger extends POILogger
{
private static LogFactory _creator = LogFactory.getFactory();
private Log log = null;
public void initialize(final String cat)
{
this.log = _creator.getInstance(cat);
}
/**
* Log a message
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The object to log.
*/
public void log(final int level, final Object obj1)
{
if(level==FATAL)
{
if(log.isFatalEnabled())
{
log.fatal(obj1);
}
}
else if(level==ERROR)
{
if(log.isErrorEnabled())
{
log.error(obj1);
}
}
else if(level==WARN)
{
if(log.isWarnEnabled())
{
log.warn(obj1);
}
}
else if(level==INFO)
{
if(log.isInfoEnabled())
{
log.info(obj1);
}
}
else if(level==DEBUG)
{
if(log.isDebugEnabled())
{
log.debug(obj1);
}
}
else
{
if(log.isTraceEnabled())
{
log.trace(obj1);
}
}
}
/**
* Log a message
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1,
final Throwable exception)
{
if(level==FATAL)
{
if(log.isFatalEnabled())
{
if(obj1 != null)
log.fatal(obj1, exception);
else
log.fatal(exception);
}
}
else if(level==ERROR)
{
if(log.isErrorEnabled())
{
if(obj1 != null)
log.error(obj1, exception);
else
log.error(exception);
}
}
else if(level==WARN)
{
if(log.isWarnEnabled())
{
if(obj1 != null)
log.warn(obj1, exception);
else
log.warn(exception);
}
}
else if(level==INFO)
{
if(log.isInfoEnabled())
{
if(obj1 != null)
log.info(obj1, exception);
else
log.info(exception);
}
}
else if(level==DEBUG)
{
if(log.isDebugEnabled())
{
if(obj1 != null)
log.debug(obj1, exception);
else
log.debug(exception);
}
}
else
{
if(log.isTraceEnabled())
{
if(obj1 != null)
log.trace(obj1, exception);
else
log.trace(exception);
}
}
}
/**
* Check if a logger is enabled to log at the specified level
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
*/
public boolean check(final int level)
{
if(level==FATAL)
{
if(log.isFatalEnabled())
{
return true;
}
}
else if(level==ERROR)
{
if(log.isErrorEnabled())
{
return true;
}
}
else if(level==WARN)
{
if(log.isWarnEnabled())
{
return true;
}
}
else if(level==INFO)
{
if(log.isInfoEnabled())
{
return true;
}
}
else if(level==DEBUG)
{
if(log.isDebugEnabled())
{
return true;
}
}
return false;
}
} // end package scope class POILogger