mirror of
https://github.com/Febbweiss/logstash-forwarder-java.git
synced 2026-03-05 06:35:44 +00:00
Implemented stdin input (issue #5).
This commit is contained in:
@@ -44,6 +44,8 @@ public class FileWatcher {
|
||||
private FileState[] savedStates;
|
||||
private int maxSignatureLength;
|
||||
private boolean tail = false;
|
||||
private Event stdinFields;
|
||||
private boolean stdinConfigured = false;
|
||||
|
||||
public FileWatcher() {
|
||||
try {
|
||||
@@ -103,6 +105,17 @@ public class FileWatcher {
|
||||
return numberOfLinesRead;
|
||||
}
|
||||
|
||||
public int readStdin(InputReader reader) throws AdapterException, IOException {
|
||||
if(stdinConfigured) {
|
||||
logger.debug("Reading stdin");
|
||||
reader.setFields(stdinFields);
|
||||
int numberOfLinesRead = reader.readInput();
|
||||
return numberOfLinesRead;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void processModifications() throws IOException {
|
||||
|
||||
for(File file : newWatchMap.keySet()) {
|
||||
@@ -224,7 +237,9 @@ public class FileWatcher {
|
||||
}
|
||||
|
||||
private void addStdIn(Event fields) {
|
||||
logger.error("Watching stdin : not implemented yet");
|
||||
logger.error("Watching stdin");
|
||||
stdinFields = fields;
|
||||
stdinConfigured = true;
|
||||
}
|
||||
|
||||
private void initializeWatchMap(File directory, IOFileFilter fileFilter, Event fields) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user