]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java
1 package org
.argeo
.slc
.runtime
.tasks
;
4 import java
.io
.IOException
;
5 import java
.lang
.System
.Logger
;
6 import java
.lang
.System
.Logger
.Level
;
7 import java
.nio
.file
.Path
;
9 import org
.apache
.commons
.io
.FileUtils
;
10 import org
.argeo
.slc
.SlcException
;
12 public class Echo
implements Runnable
{
13 private final static Logger defaultLogger
= System
.getLogger(Echo
.class.getName());
14 private Path writeTo
= null;
17 private Object message
;
20 log().log(Level
.INFO
, message
);
22 if (writeTo
!= null) {
24 File file
= writeTo
.toFile();
26 log().log(Level
.DEBUG
, () -> "Write to " + file
);
28 FileUtils
.writeStringToFile(file
, message
.toString());
29 } catch (IOException e
) {
30 throw new SlcException("Could not write to " + writeTo
, e
);
35 private Logger
log() {
36 return log
!= null ? log
: defaultLogger
;
39 public void setMessage(Object message
) {
40 this.message
= message
;
43 public void setWriteTo(Path writeTo
) {
44 this.writeTo
= writeTo
;