1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-02-01 01:37:12 +00:00

19 Commits

Author SHA1 Message Date
9e92e706bf Don't mix hash arguments with keyword arguments
Since Ruby 2.7 differences explicit keyword arguments from implicit hash
arguments, we should also avoid mixing them. By using explicit keyword
arguments, we avoid warning in Ruby 2.7 and errors in Ruby 3.0.
2019-12-18 12:56:29 +01:00
99d2f489dd Update Copyright year 2018-01-24 00:21:04 +01:00
cb95c0b0e4 Add new data-only buffering mode to Buffer
With this, the Buffer knows three buffering modes:

* :full - This is the same as the previous buffering-enabled mode. With
  this, we buffer everything and never auto-flush
* :none - the previous non-buffering mode. We autoflush everytime there
  is a new messase or explicitly added fields. All stored data is
  cleared afterwards.
* :data - the new mode. It behaves almost like :none with the notable
  exception that we retain fields and tags after the auto flush.

The new mode is especially useful to emulate a regular Logger even when
using per-request buffers. With that, you can add fields once to a
buffer. Each time a message is added, it will be flushed directly
without waiting for the request to be finished. Yet, the flows can still
take advantage of all the previously added fields and tags to properly
format the emitted log event.
2017-10-17 23:31:13 +02:00
3c27f2ae70 Remove Rackstash::Sink
The Sink was a vehicle to transport some shared state between the logger
instance and the buffers, most notably the default fields and default
tags.

It turns out however, that error handling during merging of the
default_fields and default_tags is non trivial since there, the buffer
is in sime kind of limbo: users won't write to it anymore (and thus
don't expect exceptions there) while the error handling of the
individual flows is not yet reached. Since users can specify procs in
default_fields, they can still raise for whatever user-defined reason.

Luckily, the insertion of default fields and default tags can easily be
done by a filter later anyway, under the protection of the flow's error
handling in Flow#write. This allows us just remove the whole concept of
the sink and just pass the Flows object to the Buffer.

Not having to merge default_fields during event creation significantly
simplifies Buffer#to_event which was rather ugly to begin with but now
turned out quite beatifully.
2017-10-10 11:27:32 +02:00
59c94a8ecc Insert newline comment below magic comments in ruby file header 2017-09-29 17:15:07 +02:00
168e62b63c Remove useless newlines 2017-08-12 14:02:03 +02:00
a987e92250 Add BufferStack#pop to remove the top-most Buffer without flushing it
This can be used for certain advanced constructs where the Buffer needs
to be manually flushed later, after it was already removed from the
stack.
2017-08-04 14:49:10 +02:00
7a32781c17 Return the pop'ed Buffer from the BufferStack on flush_and_pop 2017-07-25 23:32:14 +02:00
248a1d558f No need to synchronize the BufferStack with a Mutex
A single BufferStack object is only ever accessed by a single thread.
This is guaranteed by the Logger. Exceptions to the rule are not special
enough to break the rules.
2017-07-25 23:31:39 +02:00
c370aecbcd Stop splatting clean hash argument in Bufferstack#push
The optional keyword arguments are already cleaned by the keyword splat
in BufferStack#push. They are automatically unsplatted when calling
Buffer#initialize anyway.
2017-07-25 23:30:01 +02:00
a4a6b248cf Use frozen string literals throughout the codebase in Ruby >= 2.3 2017-07-17 13:35:24 +02:00
a6c6fcc90b Protect the BufferStack with a Mutex 2017-04-27 22:05:40 +02:00
2b0de27956 Return nil on BufferStacl#flush_and_pop
The buffer should not be reused after a flush anyway. By not returning
it, we ensure that it does not leak outside.
2017-04-27 22:04:13 +02:00
eea88db9a8 Document return value of BufferStack#flush_and_pop 2017-02-07 23:59:40 +01:00
728ac29432 Allow to push and pop new Buffers on the BufferStack 2017-02-04 01:19:56 +01:00
d78739d7d4 Improve documentation of Buffer and BufferStack 2017-02-04 01:02:38 +01:00
83d82fada4 Replace spiked BufferStack#with_buffer with BufferStack#current
Using a block here is unnecessary and doesn't help us with any
thread-safty guarantees on deeply nested fields or tags. Thus, we can
just remove this and replace it with a simpler method returning the
top-most buffer.

When using this buffer, we still have to ensure that only a single
Thread can access it.
2017-02-04 00:18:27 +01:00
95c8b8f8fb Pass the sink from the Logger to each individual Buffer 2017-02-03 18:43:34 +01:00
3081b03db1 Add basic logger structure with early spikes
The Rackstash::Logger class will server as the public main entry point
for users. It will eventually implement the mostly complete interface of
Ruby's Logger.

The idea of Rackstash is the we will allow to buffer multiple log
messages allong with additional data until a combined log event is
eventually flushed to an underlying log target. This allows to keep
connected log messages and data as a single unit from the start without
having to painstakingly parse and connect these in later systems again.
2017-01-18 23:34:55 +01:00