From: bruce m. <tr...@us...> - 2004-07-24 00:19:02
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26389/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: DirectoryScanner.java FtpScanner.java HttpScanner.java Log Message: Logging cleanups... 1. Created log instance variable instead of calling LogService.getInstance(). 2. All logs to debug check if debug level is set. Index: HttpScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/HttpScanner.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HttpScanner.java 3 Oct 2003 13:08:40 -0000 1.7 --- HttpScanner.java 24 Jul 2004 00:18:52 -0000 1.8 *************** *** 117,120 **** --- 117,123 ---- public static final int DEFAULT_PROXYPORT = 80; public static final int DEFAULT_TIMEOUT = 15000; + + /** logging for this class */ + private LogService log = LogService.getInstance(this.getClass().getName()); // Instance fields *************** *** 195,199 **** new UsernamePasswordCredentials(user, password)); } catch (MalformedURLException e) { ! LogService.getInstance().logError( I18n.get("scanner.HttpScanner.error.badurl", url), e); --- 198,202 ---- new UsernamePasswordCredentials(user, password)); } catch (MalformedURLException e) { ! log.logError( I18n.get("scanner.HttpScanner.error.badurl", url), e); *************** *** 223,232 **** try { // execute the method. ! LogService.getInstance().logDebug("Scanning: " + url); statusCode = httpClient.executeMethod(method); } catch (HttpRecoverableException e) { ! LogService.getInstance().logWarn( ! I18n.get( ! "scanner.HttpScanner.error.recoverable", e.getMessage())); } catch (IOException e) { --- 226,234 ---- try { // execute the method. ! if(log.isDebugEnabled()) ! log.logDebug("Scanning: " + url); statusCode = httpClient.executeMethod(method); } catch (HttpRecoverableException e) { ! log.logWarn(I18n.get("scanner.HttpScanner.error.recoverable", e.getMessage())); } catch (IOException e) { *************** *** 239,243 **** // Check that we didn't run out of retries. if (statusCode == -1) { ! LogService.getInstance().logError( I18n.get("scanner.HttpScanner.error.failed", url), null); --- 241,245 ---- // Check that we didn't run out of retries. if (statusCode == -1) { ! log.logError( I18n.get("scanner.HttpScanner.error.failed", url), null); Index: DirectoryScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/DirectoryScanner.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** DirectoryScanner.java 13 Jan 2004 11:50:23 -0000 1.26 --- DirectoryScanner.java 24 Jul 2004 00:18:52 -0000 1.27 *************** *** 99,103 **** public static final String INCLUDE_SUB_DIRS = "includeSubfolders"; public static final String FILTER_FILENAME = "filter"; ! public static final String MINIMUM_FILE_AGE = "minimumFileAge"; /** --- 99,105 ---- public static final String INCLUDE_SUB_DIRS = "includeSubfolders"; public static final String FILTER_FILENAME = "filter"; ! public static final String MINIMUM_FILE_AGE = "minimumFileAge"; ! ! private LogService log = LogService.getInstance(this.getClass().getName()); /** *************** *** 281,285 **** moveFile(files[i]); } catch (Exception ex) { ! LogService.getInstance().logError( "Error getting document from file " + files[i], ex); --- 283,287 ---- moveFile(files[i]); } catch (Exception ex) { ! log.logError( "Error getting document from file " + files[i], ex); *************** *** 345,349 **** return true; } else { ! LogService.getInstance().logDebug( "Ignoring " + file.getName() + " (age " + getFileAge(file) + " < " + getMinimumFileAge() + ")"); --- 347,352 ---- return true; } else { ! if(log.isDebugEnabled()) ! log.logDebug( "Ignoring " + file.getName() + " (age " + getFileAge(file) + " < " + getMinimumFileAge() + ")"); Index: FtpScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/FtpScanner.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** FtpScanner.java 3 Oct 2003 13:08:40 -0000 1.23 --- FtpScanner.java 24 Jul 2004 00:18:52 -0000 1.24 *************** *** 125,128 **** --- 125,131 ---- private boolean useDefaultParser = true; + /** logging for this class */ + private LogService log = LogService.getInstance(this.getClass().getName()); + public FtpScanner() { super(new FtpScannerInfo()); *************** *** 293,311 **** //check status try { ! LogService.getInstance().logDebug( ! "Checking connection status..."); ftpClient.getStatus(); } catch (Exception e) { //try to reconect ! LogService.getInstance().logDebug("Reconnecting..."); connectToHost(); } baos = new ByteArrayOutputStream(); ! LogService.getInstance().logDebug( ! "Trying to retrieve file " + fileName); boolean success = ftpClient.retrieveFile(fileName, baos); ! LogService.getInstance().logDebug("Retrieved file " + fileName); String scanFileName = fileName.substring(ftpClient.printWorkingDirectory().length()+1); //if file was retrieved without errors feed it! --- 296,315 ---- //check status try { ! if(log.isDebugEnabled()) ! log.logDebug("Checking connection status..."); ftpClient.getStatus(); } catch (Exception e) { //try to reconect ! log.logDebug("Reconnecting..."); connectToHost(); } baos = new ByteArrayOutputStream(); ! if(log.isDebugEnabled()) ! log.logDebug("Trying to retrieve file " + fileName); boolean success = ftpClient.retrieveFile(fileName, baos); ! if(log.isDebugEnabled()) ! log.logDebug("Retrieved file " + fileName); String scanFileName = fileName.substring(ftpClient.printWorkingDirectory().length()+1); //if file was retrieved without errors feed it! *************** *** 454,460 **** //This is where method begins try { ! if (LogService.getInstance().isDebugEnabled()) { ! LogService.getInstance().logDebug( ! "Scanning " + ftpClient.printWorkingDirectory()); } --- 458,464 ---- //This is where method begins try { ! if (log.isDebugEnabled()) { ! if(log.isDebugEnabled()) ! log.logDebug("Scanning " + ftpClient.printWorkingDirectory()); } *************** *** 505,509 **** String path = ftpClient.printWorkingDirectory(); path = path + "/" + ftpFiles[i].getName(); ! LogService.getInstance().logDebug("found " + path); processFile(path); } --- 509,514 ---- String path = ftpClient.printWorkingDirectory(); path = path + "/" + ftpFiles[i].getName(); ! if(log.isDebugEnabled()) ! log.logDebug("found " + path); processFile(path); } |