Class ServiceLogColoredPrintStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.PrintStream
-
- cz.xtf.core.service.logs.streaming.ServiceLogColoredPrintStream
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class ServiceLogColoredPrintStream extends PrintStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classServiceLogColoredPrintStream.Builder
-
Field Summary
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<byte[]>getTokens(byte[] buf, int off, int len)Splits the current buffer into tokens; the criteria for splitting consists in considering each new line as a token and everything else as another token.voidwrite(byte[] buf, int off, int len)Prints the data with properly colored background and foreground; takes care of adding a line header to each linevoidwrite(int b)-
Methods inherited from class java.io.PrintStream
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError
-
Methods inherited from class java.io.FilterOutputStream
write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Method Detail
-
getTokens
protected List<byte[]> getTokens(byte[] buf, int off, int len) throws IOException
Splits the current buffer into tokens; the criteria for splitting consists in considering each new line as a token and everything else as another token. If we have e.g.: "AAAA\nBBBB", we would have 3 tokens: "AAAA","\n","BBBB"; Note that a buffer not containing any new line is considered a single token e.g. buffer "AAAA" is considered as the single token "AAAA"- Parameters:
buf- the data.off- the start offset in the data.len- the number of bytes to write.- Returns:
- the list of tokens in the data; joining the tokens you get the original data.
- Throws:
IOException- in case something goes wrong while managing streams internally
-
write
public void write(int b)
- Overrides:
writein classPrintStream
-
write
public void write(byte[] buf, int off, int len)Prints the data with properly colored background and foreground; takes care of adding a line header to each line- Overrides:
writein classPrintStream- Parameters:
buf- the data.off- the start offset in the data.len- the number of bytes to write.
-
-