Skip to content

Commit ce3f70d

Browse files
committed
suppress the logger's message except when embulk log level is debug
1 parent baa67ba commit ce3f70d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ $ embulk run -Ilib example/sample.yml
5353
```
5454
$ ./gradlew gem # -t to watch change of files and rebuild continuously
5555
```
56+
57+
## Note
58+
59+
This plugin uses "org.apache.commons:commons-vfs" and the library uses the logger "org.apache.commons.logging.Log". So, this plugin suppress the logger's message except when embulk log level is debug.

src/main/java/org/embulk/output/sftp/SftpFileOutput.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ public class SftpFileOutput
4646

4747
private StandardFileSystemManager initializeStandardFileSystemManager()
4848
{
49-
// TODO: change logging format: org.apache.commons.logging.Log
50-
// System.setProperty("org.apache.commons.logging.Log",
51-
// "org.apache.commons.logging.impl.NoOpLog");
49+
if (logger.isDebugEnabled()) {
50+
// TODO: change logging format: org.apache.commons.logging.Log
51+
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
52+
}
5253
StandardFileSystemManager manager = new StandardFileSystemManager();
5354
try {
5455
manager.init();
@@ -177,8 +178,11 @@ private void closeCurrentFile()
177178
logger.error(e.getMessage());
178179
Throwables.propagate(e);
179180
}
180-
fileIndex++;
181-
currentFile = null;
181+
finally {
182+
fileIndex++;
183+
currentFile = null;
184+
currentFileOutputStream = null;
185+
}
182186
}
183187

184188
private URI getSftpFileUri(String remoteFilePath)

0 commit comments

Comments
 (0)