aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/logger/impl/StreamLogger.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/romjaki/logger/impl/StreamLogger.java')
-rw-r--r--src/main/java/de/romjaki/logger/impl/StreamLogger.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/de/romjaki/logger/impl/StreamLogger.java b/src/main/java/de/romjaki/logger/impl/StreamLogger.java
new file mode 100644
index 0000000..9428dfe
--- /dev/null
+++ b/src/main/java/de/romjaki/logger/impl/StreamLogger.java
@@ -0,0 +1,38 @@
+package de.romjaki.logger.impl;
+
+import de.romjaki.logger.Logger;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+public class StreamLogger extends Logger {
+ private Writer writer;
+
+ public StreamLogger(String name, OutputStream outputStream) {
+ this(name, new OutputStreamWriter(outputStream));
+ }
+
+ public StreamLogger(String name, Writer writer) {
+ super(name);
+ this.writer = writer;
+ }
+
+ public StreamLogger(OutputStream outputStream) {
+ this(new OutputStreamWriter(outputStream));
+ }
+
+ public StreamLogger(Writer writer) {
+ this.writer = writer;
+ }
+
+ @Override
+ protected void print(String text) {
+ try {
+ writer.write(text);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}