public void closeLogFile(String taskId) { try { logStreamCache.invalidate(taskId); } catch (Throwable throwable) { log.warn("Unable to close logfile for {}", taskId, throwable); } }
public void addLogEntry(String id, LogEntry logEntry) { try { OutputStream outputStream = logStreamCache.getUnchecked(id); ByteArrayOutputStream baos = new ByteArrayOutputStream(); objectMapper.writer().writeValue(baos, logEntry); synchronized (outputStream) { outputStream.write(("\n" + baos.size() + "\n").getBytes()); outputStream.write(baos.toByteArray()); } } catch (Throwable ignored) { // do not log errors when logging } }