use of co.rsk.net.eth.WriterMessageRecorder in project rskj by rsksmart.
the class RskSystemProperties method getMessageRecorder.
public MessageRecorder getMessageRecorder() {
if (messageRecorder != null) {
return messageRecorder;
}
if (!hasMessageRecorderEnabled()) {
return null;
}
String database = this.databaseDir();
String filename = "messages";
Path filePath;
if (Paths.get(database).isAbsolute()) {
filePath = Paths.get(database, filename);
} else {
filePath = Paths.get(System.getProperty("user.dir"), database, filename);
}
String fullFilename = filePath.toString();
MessageFilter filter = new MessageFilter(this.getMessageRecorderCommands());
try {
messageRecorder = new WriterMessageRecorder(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fullFilename), StandardCharsets.UTF_8)), filter);
} catch (IOException ex) {
logger.error("Exception creating message recorder: ", ex);
}
return messageRecorder;
}
use of co.rsk.net.eth.WriterMessageRecorder in project rskj by rsksmart.
the class RskContext method getMessageRecorder.
private MessageRecorder getMessageRecorder() {
if (writerMessageRecorder == null) {
RskSystemProperties rskSystemProperties = getRskSystemProperties();
if (!rskSystemProperties.hasMessageRecorderEnabled()) {
return null;
}
Path filePath = FileUtil.getDatabaseDirectoryPath(rskSystemProperties.databaseDir(), "messages");
String fullFilename = filePath.toString();
MessageFilter filter = new MessageFilter(rskSystemProperties.getMessageRecorderCommands());
try {
// This resource needs to remain open when method returns, so LGTM warning is disabled.
writerMessageRecorder = new WriterMessageRecorder(new BufferedWriter(// lgtm [java/output-resource-leak]
new OutputStreamWriter(new FileOutputStream(fullFilename), StandardCharsets.UTF_8)), filter);
} catch (IOException ex) {
throw new IllegalArgumentException("Can't use this path to record messages", ex);
}
}
return writerMessageRecorder;
}
Aggregations