aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/logger/impl/StreamLogger.java
blob: 9428dfe334aaf7207a1745b4c8d493a14a27df39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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();
        }
    }
}