I need to integrate FastCSV and tinylog. I hoped it will be easy but it's turned out that event though current tinylog API seemed extensible, when I start implementing integration, I found it quite limited.
I need csv writer to be applied after Logger.info() method call. Only way I see is to implement custom writer but it doesn't work, because LogEntry expects message to be string i.e. object -> csv serialization should happen in advance.
Another way is to provide tinylog log .info() call as Writer implementation into CsvWriter, but it won't work too because of the same limitation - LogEntry expects string and Logger.info() expects string too:
CsvWriter writer = CsvWriter.builder().lineDelimiter(LineDelimiter.LF).build(new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
Logger.info(.......?????)
}
@Override
public void flush() throws IOException {
???
}
@Override
public void close() throws IOException {
????
}
});
If I'll serialize to csv in advance then I won't be able to leverage Tinylog's shutdown hook/writing thread and other features:
public class TinylogEventLogger implements EventLogger {
@Override
public void log(Event event) {
String csvLine = toCsvLine(event);
logger.info(csvLine);
}
private String toCsvLine(Event event) {
final Writer csv = new StringWriter();
CsvWriter writer = CsvWriter.builder().lineDelimiter(LineDelimiter.LF).build(csv);
writer.writeRow(toColumns(event));
return csv.toString();
}
}
Could you please guide me and advice possible ways of integration? I don't mind to send a patch but would be great to discuss it first to be on the same page about how to approach it.
I need to integrate FastCSV and tinylog. I hoped it will be easy but it's turned out that event though current tinylog API seemed extensible, when I start implementing integration, I found it quite limited.
I need csv writer to be applied after
Logger.info()
method call. Only way I see is to implement custom writer but it doesn't work, because LogEntry expects message to be string i.e. object -> csv serialization should happen in advance.Another way is to provide tinylog log .info() call as Writer implementation into CsvWriter, but it won't work too because of the same limitation - LogEntry expects string and Logger.info() expects string too:
If I'll serialize to csv in advance then I won't be able to leverage Tinylog's shutdown hook/writing thread and other features:
Could you please guide me and advice possible ways of integration? I don't mind to send a patch but would be great to discuss it first to be on the same page about how to approach it.
Thanks