karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5747) Add append file capability in decanter-appender-file
Date Mon, 11 Jun 2018 16:46:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16508346#comment-16508346
] 

ASF GitHub Bot commented on KARAF-5747:
---------------------------------------

jbonofre closed pull request #34: [KARAF-5747] Add append file capability in decanter-appender-file
URL: https://github.com/apache/karaf-decanter/pull/34
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/appender/file/src/main/cfg/org.apache.karaf.decanter.appender.file.cfg b/appender/file/src/main/cfg/org.apache.karaf.decanter.appender.file.cfg
index ee487cb..78a86c3 100644
--- a/appender/file/src/main/cfg/org.apache.karaf.decanter.appender.file.cfg
+++ b/appender/file/src/main/cfg/org.apache.karaf.decanter.appender.file.cfg
@@ -6,4 +6,7 @@
 #filename=${karaf.data}/decanter
 
 # Marshaller
-marshaller.target=(dataFormat=csv)
\ No newline at end of file
+marshaller.target=(dataFormat=csv)
+
+# Append file
+#append=true
\ No newline at end of file
diff --git a/appender/file/src/main/java/org/apache/karaf/decanter/appender/file/FileAppender.java
b/appender/file/src/main/java/org/apache/karaf/decanter/appender/file/FileAppender.java
index f916eff..713d9fa 100644
--- a/appender/file/src/main/java/org/apache/karaf/decanter/appender/file/FileAppender.java
+++ b/appender/file/src/main/java/org/apache/karaf/decanter/appender/file/FileAppender.java
@@ -43,10 +43,13 @@
 
     private BufferedWriter writer;
 
+    private boolean append;
+
     @Activate
     public void activate(ComponentContext componentContext) throws Exception {
         Dictionary<String, Object> config = componentContext.getProperties();
         String filename = (config.get("filename") != null) ? (String) config.get("filename")
: System.getProperty("karaf.data") + File.separator + "decanter";
+        append = (config.get("append") != null) ? Boolean.parseBoolean((String) config.get("append"))
: true;
         open(filename);
     }
 
@@ -54,7 +57,7 @@ public void open(String filename) throws Exception {
         File file = new File(filename);
         file.getParentFile().mkdirs();
         file.createNewFile();
-        this.writer = new BufferedWriter(new FileWriter(file));
+        this.writer = new BufferedWriter(new FileWriter(file, append));
     }
 
     @Override


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add append file capability in decanter-appender-file
> ----------------------------------------------------
>
>                 Key: KARAF-5747
>                 URL: https://issues.apache.org/jira/browse/KARAF-5747
>             Project: Karaf
>          Issue Type: Improvement
>          Components: decanter
>            Reporter: Francois Papon
>            Assignee: Francois Papon
>            Priority: Minor
>             Fix For: decanter-2.1.0
>
>
> The file created by the appender is cleaned at bootstrapping if already exist.
> The use could choose if the appender append or not in the file already exist.
> We could add a new property in the configuration file of the appender.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message