1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-12-27 09:51:12 +00:00

212 Commits

Author SHA1 Message Date
0fa327bb3a Don't refer to methods not available on the current class in yard docs 2017-08-04 14:38:24 +02:00
285e012815 Fix code location in comment describing the need for Ruby 2.1 2017-08-04 11:10:20 +02:00
c22174e0e9 Remove "ref" dependency since we are not using it 2017-08-04 01:05:46 +02:00
3f8745e32c Move the responsiblity for creating the event hash to the Buffer
With this move, we can also optimize the sinplest case where there are
no fields or tags on the Buffer and no defines default_fields or
default_tags on the Sink. In that case, we don't need to merge them,
avoiding the creation of several unecessary objects on Buffer flush.
2017-08-04 00:53:36 +02:00
4438bf42bc Lazy instanciate tags and fields on a Buffer instance 2017-08-03 22:31:48 +02:00
697641635b Don't use Concurrent::{Hash|Array} objects in Fields
Since the fields are (through the thread-local BufferStack) only ever
accessed from a single Thread, there is no need to accept the additional
locking overhead of the Concurrent raw values.

We can just use simple Hashes and Arrays here for higher performance.
2017-08-03 21:09:50 +02:00
65e272347d Preemptively freeze more Strings on normalize to ensure that we don't create unnecessary copies 2017-08-02 19:59:18 +02:00
ab7331a7a9 Fix code intentation 2017-08-02 19:59:10 +02:00
271c547f05 Initialize monitor and copy internal filters list on FilterChain#dup 2017-08-02 17:50:53 +02:00
6c145579ed Add FilterChain#to_a to get a plain Array representation of the chain 2017-08-02 17:37:29 +02:00
597f605e06 Don't stub FilterChain#to_s in test of #inspect
That way, we can also ensure that the nested locking works correctly
without any deadlock.
2017-08-02 17:32:10 +02:00
cbcfec88a8 Synchronize FilterChain#to_s and FilterChain#inspect
This ensures that any access to the internal @filters array is only done
with an aquired lock to ensure data consistency.
2017-08-02 17:29:27 +02:00
f6c5930db6 Use __dir__ instead of deriving from __FILE__ where suitable 2017-08-02 16:06:21 +02:00
b228494d14 Raise a custom Rackstash::NotImplementedHereError instead of NotImplementedError
Using the core `NotInmplementedError` is not desireable since its
documentation includes:

> Note that if `fork` raises a `NotImplementedError`, then
> `respond_to?(:fork)` returns `false`.

Since we are responding to the method but still raise an error, our
usage of the exception does not fulfill its documentation.

A custom error instead of a default `NoMethodError` is still desireable
since it significantly helps with debugging. With a different Exception,
we make it clear that a method is expected to be there and just wasn't
implemented by a subclass as opposed to the caller just using an object
wrong and calling entirely unexpected methods on it.
2017-08-01 12:28:58 +02:00
4eb381a733 Move Logger#add_exception to the Buffer and forward from the Logger 2017-07-28 16:58:51 +02:00
65cad497f0 Add complete tests for setting a custom error_flow on Flows 2017-07-28 12:59:46 +02:00
c4f0b9cdeb Use an error_flow to log any exceptions during logging
During normal operation, the Flows will rescue all exceptions and log
them to the special error_flow. By default, we will write JSON logs to
STDERR.

The log location and format can either be change globally by setting (or
changing) the Rackstash.error_flow or for each Flow for a Logger
individually by setting Flow#error_flow.
2017-07-28 02:16:31 +02:00
fb7732ef42 Extract close!, reopen!, and write! methods from Rackstash::Flow
These methods do not rescue any thrown errors. The usual loggers will
always want to use the non-bang methods which rescue errors and attempt
to log them.
2017-07-27 23:15:59 +02:00
dcf21d0bfa Synchronize all writes of the IO adapter against the underlying IO object 2017-07-27 18:06:48 +02:00
be6e3517de Increase sub-second precision of timestamps to 6 decimal places 2017-07-25 23:32:14 +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
f92bde5af2 Add Logger#[] and Logger#[]= alias methods to get and set fields 2017-07-25 00:03:47 +02:00
12261ef786 Fix Typo in spec description 2017-07-22 00:07:18 +02:00
9656297762 Remove ANSI color codes from the message in JSON encoder 2017-07-22 00:06:35 +02:00
da97e9d54e Inline Message#cleanup to save one method invocation per log line 2017-07-21 23:39:17 +02:00
05145b400b Fix Typo 2017-07-21 23:34:29 +02:00
667beb662f Freeze Messages directly after initialization
This ensures that they are actually immutable.
2017-07-21 22:50:44 +02:00
57f200ab35 Check that Logger#tag implements the same interface as Buffer#tag 2017-07-21 18:34:50 +02:00
9536b0473b Forward Logger#timestamp to Buffer#timestamp 2017-07-21 18:34:29 +02:00
5213574ec7 Don't include Forwardable into Rackstash::Logger anymore, we are not using it 2017-07-21 17:12:46 +02:00
cce94b70ed Explicitly require concurrent gem for Buffer class 2017-07-21 17:06:37 +02:00
1b81e763b2 Improve documentation for Sink#default_* accessors 2017-07-21 17:04:25 +02:00
c53d85fac5 Forward Logger#tag to the current Buffer 2017-07-21 16:57:44 +02:00
fc4a917b71 Forward Logger#close and Logger#reopen to the Sink 2017-07-21 16:44:11 +02:00
40f920dafb Forward config methods for the Sink on the Logger 2017-07-21 16:37:47 +02:00
1d67d819d0 Complete code documentation of Rackstash::Message 2017-07-20 23:46:03 +02:00
25dfa87de7 Add Rackstash::Logger#add_exception to easily add details about exceptions as buffer fields 2017-07-20 23:19:06 +02:00
d9ea199d4f Remove useless variable assignment in logger spec 2017-07-20 22:49:03 +02:00
67955f8629 Add force parameter to Rackstash::Fields::Hash#set so it works like #merge! 2017-07-20 22:11:11 +02:00
9fc9ea248b Use Rackstash::Helpers::UTF8 in Message class 2017-07-20 14:12:05 +02:00
d73b7ba8e1 Extract utf8_encode helper into Rackstash::Helpers::UTF8 module 2017-07-20 14:12:05 +02:00
2c8d6ac009 Don't cleanup ANSI chars and newlines in messages anymore
These characters might be there deliberately. If they should be cleaned
up, it can easily be done later with a filter.
2017-07-20 13:45:55 +02:00
ba3e0676e5 Test for invalid matchers for registered Adapters
Yes, this commit is required only because of my unhealthy urge to
achieve real 100% test coverage...
2017-07-20 01:25:16 +02:00
5eeaab4afa Allow to overwrite logger attributes in Logger#initialize 2017-07-20 00:47:26 +02:00
4a62e3d189 Allow to write a Hash to the Logger to deep_merge fields 2017-07-20 00:29:43 +02:00
33ee63bffb Improve code documentation for Logger 2017-07-20 00:20:23 +02:00
4e1f6af273 Use the same argument names in Logger methods 2017-07-20 00:18:41 +02:00
720406b318 Implement the full Sink class
A single Sink is tied to a single Logger. It is responsible to:

* Create a log event from a Buffer on #write and send it to each of the
  flows independently.
* Forward all actions to all of the defined Flows.

The Sink provides access to all configured data of the Logger which is
used for persisting the Buffers.
2017-07-20 00:06:06 +02:00