mirror of https://github.com/status-im/timbre.git
[#195] Logstash appender: add `:flush?` option (@tvanhens)
Setting the value to true will eagerly flush the tcp writer. Default behavior is for this to be false.
This commit is contained in:
parent
ef8592f27d
commit
e9c5dc0479
|
@ -50,9 +50,11 @@
|
|||
format to the logstash server at `host:port`. Additionally `opts`
|
||||
may be a map with `:pr-stracktrace` mapped to a function taking an
|
||||
exception, which should write the stacktrace of that exception to
|
||||
`*out`."
|
||||
`*out`. Set `:flush?` to true to flush the writer after every
|
||||
event."
|
||||
[host port & [opts]]
|
||||
(let [conn (atom nil)
|
||||
flush? (or (:flush? opts) false)
|
||||
nl "\n"]
|
||||
{:enabled? true
|
||||
:async? false
|
||||
|
@ -69,6 +71,7 @@
|
|||
(locking sock
|
||||
(data->json-stream data out (select-keys opts [:pr-stacktrace]))
|
||||
;; logstash tcp input plugin: "each event is assumed to be one line of text".
|
||||
(.write ^java.io.Writer out nl)))
|
||||
(.write ^java.io.Writer out nl)
|
||||
(when flush? (.flush ^java.io.Writer out))))
|
||||
(catch java.io.IOException _
|
||||
nil)))}))
|
||||
|
|
Loading…
Reference in New Issue