mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-10 07:52:46 +00:00
Add logToFile support to DecideRuleSequence. File is logs/{spring-bean-id}.log,
format: [timestamp] [decisive-rule-num] [decisive-rule-class] [decision] [uri]
* Scoper.java
start(),stop() - call scope.start()/scope.stop()
* CrawlerLoggerModule.java
setupSimpleLog() - new logToFile paradigm
* DecideRule.java
start(),stop() - noop
* DecideRuleSequence.java
logToFile support
* profile-crawler-beans.cxml
<!-- <property name="logToFile" /> -->
This commit is contained in:
1 parent
641f193e17
commit
93cf655bed
5 files changed
+87
-5
No files matched your search
@@ -107,6 +107,7 @@ public abstract class Scoper extends Processor implements Lifecycle {
|
||||
this.getClass().getName(),
|
||||
Logger.getLogger(this.getClass().getName()));
|
||||
}
|
||||
scope.start();
|
||||
isRunning = true;
|
||||
}
|
||||
|
||||
@@ -117,6 +118,7 @@ public abstract class Scoper extends Processor implements Lifecycle {
|
||||
if(fileLogger!=null) {
|
||||
fileLogger.close();
|
||||
}
|
||||
scope.stop();
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ package org.archive.crawler.reporting;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.FileHandler;
|
||||
@@ -271,7 +273,29 @@ public class CrawlerLoggerModule
|
||||
this.fileHandlers.put(logger, fh);
|
||||
}
|
||||
|
||||
|
||||
public Logger setupSimpleLog(String logName) {
|
||||
Logger logger = Logger.getLogger(logName + ".log");
|
||||
|
||||
Formatter f = new Formatter() {
|
||||
private SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd+HH:mm:ss.SSS");
|
||||
|
||||
public String format(java.util.logging.LogRecord record) {
|
||||
String timestamp = dateFmt.format(new Date(record.getMillis()));
|
||||
return timestamp + " " + record.getMessage() + '\n';
|
||||
}
|
||||
};
|
||||
|
||||
ConfigPath logPath = new ConfigPath(logName + ".log", logName + ".log");
|
||||
logPath.setBase(getPath());
|
||||
try {
|
||||
setupLogFile(logger, logPath.getFile().getAbsolutePath(), f, true);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
return logger;
|
||||
}
|
||||
|
||||
private void setupAlertLog(String logsPath) throws IOException {
|
||||
Logger logger = Logger.getLogger(LOGNAME_ALERTS + "." + logsPath);
|
||||
String filename = getAlertsLogPath().getFile().getAbsolutePath();
|
||||
|
||||
Reference in new issue
Block a user