1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

156 Commits

Author SHA1 Message Date
b6768c6547 Test all conditions of Rackstash::Fields::Hash() 2017-07-19 12:02:21 +02:00
b72b8cf94b Fix @return documentation tag for Rackstash::Filters::SkipEvent#call 2017-07-19 11:09:32 +02:00
9950d783cf Ensure behavior of Rackstash::Adapters::File#auto_reopen? 2017-07-19 00:40:47 +02:00
0420984d92 Ensure more reliable concurrency in tests for Rackstash::Adapters::File 2017-07-19 00:27:35 +02:00
2ff1e1e5dc Ensure Rackstash::Fields::Tags.merge! accepts nested procs 2017-07-18 23:33:48 +02:00
dc3d2b20bf Add tests and clarify edge-case for Rackstash.severity_label 2017-07-18 23:28:26 +02:00
d609c2409a Fix test condition in file adapter cncurrency spec
Previously, we have counted successivly equal lines. However, we want to
count the number of lines with different content to ensure proper
concurrency during the test.
2017-07-18 23:13:35 +02:00
e21108b7c2 Add first example SkipEvent filter 2017-07-18 23:13:35 +02:00
466c377565 Add FilterChain to wrap and filters on event hashes 2017-07-18 16:49:04 +02:00
a4a6b248cf Use frozen string literals throughout the codebase in Ruby >= 2.3 2017-07-17 13:35:24 +02:00
e3611c8720 Add Message#severity_label and Message#length utility methods 2017-07-17 12:00:13 +02:00
364426f228 Return the flows object in Rackstash::Flows#each 2017-07-15 16:27:09 +02:00
1da5ae4a38 Extract unrelated constant tests 2017-07-15 14:32:09 +02:00
724a373d66 Add MIT license header to file adapter spec 2017-07-15 14:30:07 +02:00
ba61940a95 Improve code formatting 2017-07-15 14:30:07 +02:00
9f2a330a6c Support arbitrarily nested Procs when setting/merging fields 2017-07-15 11:13:41 +02:00
dd7f79db0a No need to freeze Strings from utf8_encode again in Fields::Tags 2017-07-15 10:50:55 +02:00
2f33e10ba9 Clarify that Buffer#add_message also sets the timestamp 2017-07-14 11:05:19 +02:00
0cf89200f2 Use Arry.new(n) {...} instead of n.times.map {...} 2017-07-12 12:27:57 +02:00
0d1ad5e170 Add basic documentation for Rackstash::Fields 2017-07-11 23:52:49 +02:00
637245d836 Don't detail other adapters in IO adapter documentation 2017-07-11 23:43:48 +02:00
ee429fa71e Add Rackstash::Fields::Array#shift and #unshift 2017-07-11 23:42:13 +02:00
779f3bb81d Improve code documentation of Rackstash::Fields 2017-07-11 23:42:13 +02:00
a461b36b97 Allow to query and replace subarrays of Rackstash::Fields::Array 2017-07-11 23:42:13 +02:00
d07a9452f4 Add Rackstash::UNDEFINED constant
The {UNDEFINED} object can be used as the default value for method
arguments to distinguish it from `nil`. See
https://holgerjust.de/2016/detecting-default-arguments-in-ruby/#special-default-value
for details.
2017-07-11 23:42:13 +02:00
da1999dba3 Unify the conflict resolution behavior of merge! and deep_merge! in Rackstash::Fields::Hash
When setting `force: true` (the default), in both cases we not raise an
ArgumentError when setting a forbidden field and overwrite existing
fields. When setting it to `false`, we ignore forbidden or existing
fields in both cases.

We also allow a custom conflict resolution block to be passed to both
methods. In the case of deep_merge! and deep_merge, this applies to all
(potentially deeply nested) fields. Compatible objects, i.e. Hashes and
Arrays are still always merged without calling the block.
2017-07-11 22:23:19 +02:00
a0c92d57f8 Add File adapter to directly write to a local file 2017-07-10 23:45:02 +02:00
e96a0aaf94 Separate the PRERELEASE version part with a dash instead of a dot 2017-07-05 19:21:24 +02:00
d6c3111999 Always generate positive object IDs in inspect
Sometimes, object_ids are created as signed Integers which are invalid
in `inspect`. By using the default implementation of `Object#to_s`, we
can get valid object_ids the same way Ruby itself would have created
them.

For a motivation of this change, see

* https://bugs.ruby-lang.org/issues/13397
* https://github.com/ruby-concurrency/concurrent-ruby/pull/651
2017-07-03 13:37:05 +02:00
4eecc559a4 Transform list of forbidden_keys in Rackstash::Fields::Hash.new to a frozen Set
We then expose this frozen Set on the `forbidden_keys` attribute.
2017-06-30 19:27:46 +02:00
d26858c103 Add Rackstash::Fields::Array#size as an alias to length 2017-06-22 23:00:51 +02:00
7c0c983dc2 Add Message encoder to just log the log message
This encoder is useful for local consumption of the raw log stream, e.g.
during development where the developer might not care for any additional
fields. With this encoder, the log output can mostly resemble a "classic"
line-based log feed.
2017-06-21 01:38:11 +02:00
e29c8976bb Clarify that the JSON encoder strips all whitespace 2017-06-21 01:38:11 +02:00
32b3ef8e0e Add Rackstash::Fields::Array#pop
This method does exactly the same as `::Array#pop`
2017-06-21 01:38:11 +02:00
649de80698 Allow multiple arguments to Rackstash::Fields::Array#push
We now also support the new alias to `Array#push` called `append` which
will be added to the core `Array` with Ruby 2.5.
2017-06-21 01:38:11 +02:00
6eccf6cc37 Don't copy or alter frozen UTF-8 strings in fields
With this, we optimize the common case where we do have valid UTF-8
strings to begin with. If the given String is already frozen, as is
common for e.g. Hash keys, we don't even need to create a new object.

With this change, we also always return frozen strings from
`Rackstash::Fields::AbstractCollection#utf9_encode`. This avoids an
unecessary object copy when inserting it in a Hash and still ensures
that values are always frozen anyway.
2017-06-21 01:38:11 +02:00
aad1660135 Add Callable adapter to handle a log in a custom way
Users can provide a "callable", i.e. a proc or block which will be
called for each written log. This allows users to custom handle the
logs without having to write a full adapter.

Usually, users should still write a full adapter to handle all cases of
their wrapped log device.
2017-06-21 01:38:11 +02:00
0aa39483dd Add Raw encoder which just passes the log event 2017-06-16 23:04:55 +02:00
16d76a7217 Allow to automatically flush the IO adapter after each write 2017-06-16 23:04:55 +02:00
00786283f0 Add IO adapter
This adapter allows to write newline-separated log lines to an existing
IO object, e.g. STDOUT. It does not allow to reopen the IO device.
2017-06-16 23:04:55 +02:00
b3f9a63253 Allow to define a suitable default encoder per adapter
The global default (unless overwritten by an adapter class) is to use
the JSON encoder since it's the most versatile and flexible option for a
logger today.
2017-06-16 23:04:55 +02:00
bf178ef36d Add JSON encoder 2017-06-16 23:04:54 +02:00
05f0faeedc Add abstract adapter and adapter registry
An ada pert wraps a log device (e.g. a file, an underlying logger, ...)
and provides an uniform interface to write the encoded log event to its
final target.

By using a registry, we can create the required adapter instance for a
provided log device automatically.
2017-06-16 23:04:54 +02:00
f4e85f7013 Use a Concurrent::Hash instead of a Set for Fields::Tags
This makes the Rackstash::Fields::Tags class thread safe while still
mantaining its existing semantincs, given that Ruby's set is also build
on top of a simple Hash.
2017-06-16 23:04:54 +02:00
db8a5e50b5 Improve code documentation 2017-06-16 23:04:54 +02:00
1a73062758 Avoid Array instances when JSON'ifying Arrays / Hashes
Similar to the previous commit, we avoid the unnecessary allocation of
a temporary array when looping over the `@raw` value. In addition to
that, we ensure thread-safety by always operating on a copy of the raw
data so that other threads can not change anything under our feet
anymore.
2017-06-16 23:04:54 +02:00
da3113e880 Avoid Array instances when normalizing Arrays / Hashes
`each_with_object` allocates an array for each kv pair. Switching to
the slightly more verbose but less allocatey `each_pair` eliminates
array allocations.

This follows the similar change in Rails:
960de47f0e
2017-05-23 13:27:22 +02:00
9b7549b4d0 Add comment explaining the required_ruby_version to gemspec 2017-05-09 22:38:43 +02:00
253543fbad Add README 2017-05-09 22:38:06 +02:00
7ffdc527af Ensure we are only adding actual Flow objects in Rackstash::Flows.new 2017-05-09 22:22:25 +02:00