1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-12-26 17:31:13 +00:00

271 Commits

Author SHA1 Message Date
bcc481bfbe Test that a Logger can be created without defining flows 2017-09-21 22:29:39 +02:00
20e3f28273 Return the given value on Flows#[]= 2017-09-21 22:27:13 +02:00
14479e97dd Avoid creating additional array instance on Flows#to_ary 2017-09-21 22:26:27 +02:00
060c4f3e8b Fix comment typo 2017-09-21 22:23:06 +02:00
070df582e7 Describe how to create a Logger instance 2017-09-21 16:21:40 +02:00
a31f07f7c2 Yield the last created flow on Logger.new
This allows to configure the last (and often only) flow on creation of
the Logger without having to manually create the object. We can thus use
the following shortcut to e.g. set a custom encoder:

    Rackstash::Logger.new(STDOUT) do
      encoder Rackstash::Encoder::Message.new
    end
2017-09-21 16:18:46 +02:00
7ba96043a5 Bump Ruby minor versions in .travis.yml 2017-09-18 12:47:22 +02:00
74242caf0b There can be only one... UNDEFINED
By ensuring that we only ever create a single UNDEFINED object from the
UndefinedClass, it behaves more like nil
2017-09-07 21:18:03 +02:00
32e755396b Splat flows/adapters passed to Rackstash::Logger#initialize
This ensures that we are not unduely altering (i.e. flattening) adapter
specifications when creating the flows.
2017-08-31 21:59:48 +02:00
180faf9a55 Update contact information in code of conduct 2017-08-30 01:04:53 +02:00
cadc235795 Add Helpers::Time module to access a monotonic clock 2017-08-30 01:01:15 +02:00
6e58dc19b3 Correct documentation of Rackstash::FilterChain 2017-08-30 00:39:08 +02:00
8b75013472 Test that the Lograge encoder skips messages 2017-08-24 23:17:20 +02:00
b101d7356a Add lograge encoder
This encoder formats logs similar to the key-value formatter of the
lograge gem.
2017-08-24 23:07:17 +02:00
40aa74c5c0 Always add a @timestamp field in the logstash encoder, even if it was removed by a filter 2017-08-24 23:07:17 +02:00
7b06d053ca Create an error event in the Flow exactly as a Buffer would
That way, we ensure that the error_flow receives an expected event and
doesn;t have to deal with different data formats which might result in
additional (then quietly hidden) errors.
2017-08-24 23:07:17 +02:00
96aaaa0348 Set Encoder helper methods as private
That way, they don't pollute the public interface of the encoders
including the helpers modules.
2017-08-24 23:07:17 +02:00
3078bccafd Pass the raw Buffer timestamp through the event Hash
This allows filters and finally the encoder to use this without having
to first convert the timestamp (back) to a more suitable format.
2017-08-24 23:07:17 +02:00
99728842aa Pass the raw messages array in the event Hash to the encoder
The encoder is then responsible to format it as it pleases. Commonly,
encoders can use Rackstash::Encoders::Helpers::Message#normalize_message
to create a single combined message string.

If the encoder is not interested in using the message, it can jsut get
rid if it without incuring any overhead.
2017-08-22 00:02:10 +02:00
78466f9439 Set the Buffer's timestamp when setting a tag 2017-08-17 00:49:10 +02:00
ff50daf1eb Fix documentation for Buffer#tags and Buffer#fields 2017-08-17 00:48:47 +02:00
021dbc256b Flush silent Buffers by default
With the change to allow ading fields to the Buffer with a Logger
interface in the previous commit, we should also flush those Buffers
with fields set that way by default.
2017-08-17 00:34:47 +02:00
013d0f7d92 Auto-flush the buffer when adding fields using Logger#add
With this interface, the user adds fields the same way they would add
messages. The implicit assumption here is that the buffer is handled the
same way. Thus, if the current buffer is non-buffering, we will
automatically flush it to the sink and clear it, just the same way as we
would have done it for a message.
2017-08-17 00:34:47 +02:00
4baa1b97f6 Extract Buffer#auto_flush method
This method is responsible to automatically flish non-buffering Buffers
when there are messages added
2017-08-17 00:07:21 +02:00
cca00408e2 With allow_silent, also check the presence of an explicit timestamp for Buffer#pending? 2017-08-16 20:54:55 +02:00
d8300a125e Rename Buffer#allow_empty? to Buffer#allow_silent?
This new name better reflects what this option actually does: it allows
to flush a Buffer even if there were just added fields or tags. A tryely
empty Buffer, i.e., one which has neither added messages, fields, or
tags is never flushed.
2017-08-16 20:46:28 +02:00
0a5e0a4aab Add TruncateMessage filter to restrict the size of the logged message 2017-08-16 00:43:09 +02:00
ee1f5480c4 Remove useless assignments in message_spec 2017-08-15 23:45:54 +02:00
6558c4b63f Require the Message encoder on load 2017-08-15 22:15:39 +02:00
2da9bdd212 Require the Logstash encoder on load 2017-08-15 22:11:43 +02:00
fa174bba9d Freeze the raw object along the wrapper for all fields 2017-08-15 18:36:33 +02:00
57f1197299 Do not alter the message in JSON encoder
If required, users can setup filters for that. We shouldnot assume any
overly specific use-cases here.
2017-08-14 23:25:59 +02:00
cc8e5db6b4 Remove useless newline 2017-08-14 23:19:11 +02:00
0a1fe46ea5 Add filter to remove all ANSI color codes from the event message 2017-08-14 23:18:19 +02:00
10993d2b1a Serialize Rational numbers to a String
With this, we are more compatible with the common JSON encoders,
including the one on RUby core.
2017-08-14 14:10:48 +02:00
ab595d031b Add Logstash encoder
This encoder is very similar to the JSON encoder. It handles a few
additional specifics for Logstash to be suotable for Logstash's json
input.
2017-08-14 13:33:52 +02:00
2fbdf3c1f5 Don't create the @version fields in events by default
This field is only relevant when actually sending JSON to Logstash.
Other formats don't need it. It is thus more desireable to only include
this field in a specific logstash JSON encoder.
2017-08-14 13:27:20 +02:00
536bb9a087 Ensure that the Formatter freezes the strings in all cases
Previously, the returned String would been frozen only in Rubies
understanding the frozen_literals magic comment.
2017-08-12 14:05:20 +02:00
168e62b63c Remove useless newlines 2017-08-12 14:02:03 +02:00
3a1f3686c0 Add Message#strip methods to strip whitespace from messages
These mehods work very similar to their String equivalents.
2017-08-08 22:26:34 +02:00
e999746f1e Add Message#gsub and Message#sub methods
These allow to create new Message objects with an updated message,
similar to `gsub` and `sub` of the core String.
2017-08-08 22:15:21 +02:00
eb93d70468 Add Message#copy_with to create an adjusted copy of an exising message
You can overwrite any (or none) of the existing fields to create a new
frozen copy of a message object.
2017-08-08 22:15:13 +02:00
011249bb75 Add Flows#first and Flows#last 2017-08-07 22:49:39 +02:00
eab3d16ec5 Fix minor code formatting issues 2017-08-05 23:53:01 +02:00
d362b7efaa Make Flow#unshift_filter the primary alias before filter_prepend to be more consistent 2017-08-05 23:29:54 +02:00
581b8b1819 Allow to insert a new filter defined by a symbol or String into a FilterChain 2017-08-05 23:29:54 +02:00
f0c65524a7 Build a new Filter from a String or Symbol 2017-08-05 23:29:54 +02:00
9e23267c76 Enforce RuboCop style to write empty methods on two lines 2017-08-05 18:48:43 +02:00
ce9cc0f8b4 Disable RuboCop check for conditional assignment
It is not universally useful to enfore a single assignment mode. With
short conditionals (or even a ternary operator), an assignment of the
returned value is common. For longer or more complex conditionals, I
perfer an assignment inside the condition to decouple the conditional
checks from the assignment logic.
2017-08-05 18:44:52 +02:00
8c7900f17b Refactor: extract checks in FilterChain 2017-08-05 15:47:17 +02:00