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

65 Commits

Author SHA1 Message Date
8232d139f4 Add specs for handling of nested procs inside arrays with fields 2017-02-16 00:39:08 +01:00
bd376af884 Use thread-safe raw objects for field hashes and arrays 2017-02-14 22:47:55 +01:00
3ec21e7646 Always resolve procs when setting them into fields 2017-02-13 23:37:02 +01:00
5fc679a63a Document additional public methods 2017-02-10 23:48:49 +01:00
ad038f4317 Add Rackstash::Fields::Array#<< to add a value at the end of the array 2017-02-10 23:22:41 +01:00
ebd2a19251 Test that Logger#add sets the current formatter on the message 2017-02-09 23:31:48 +01:00
68a2b57e28 Add Logger#<< to ad a raw unformatted message to the buffer
If the current Buffer is bufering, the message will just be added. Else,
it will be flushed to the sink directly.
2017-02-09 14:13:31 +01:00
031198cf14 Add Hash#set to set a field from a block if it doesn't exist yet
This allows to define default values for certain fields which can be
inserted just before a Buffer is flushed. They won;t overwrite prior
user-provided fields.

Through the use of a block, expensive calculations for a field could be
avoided if the field is not going to be inserted, e.g. because it exists
already or is forbidden from being set.
2017-02-09 00:15:18 +01:00
ea77a8ae26 Add bare-bones CHANGELOG 2017-02-08 00:03:24 +01:00
62dea60216 Add a more specific test name 2017-02-08 00:02:22 +01:00
52645e67ac Refer to Rackstash::SEVERITIES in Logger#add method docs only
There is no explicit need to repeat the constants here.
2017-02-08 00:00:42 +01:00
eea88db9a8 Document return value of BufferStack#flush_and_pop 2017-02-07 23:59:40 +01:00
1a43ed828b Use documentation format in rspec again
It's more useful in CI to see what happens exactly and where eventual
warnings occur.
2017-02-07 23:56:53 +01:00
2e39d6f007 Add Logger#with_buffer to add a new buffering buffer to the stack 2017-02-07 23:39:06 +01:00
6667c06519 Add Logger#fields and Logger#tags for direct access to the current Buffer's fields and tags 2017-02-07 23:39:06 +01:00
8b1fc7e30e Add .yardopts for code documentation 2017-02-07 00:14:36 +01:00
fdb3565d85 Add documentation for Rackstash::Fields::Hash 2017-02-07 00:13:05 +01:00
c260d9b154 Don't refer to the (non-existing yet) rack middleware in the docs 2017-02-05 21:21:32 +01:00
d489b6e26a Ensure Rackstash::FIELD_* constants are frozen strings 2017-02-05 21:18:32 +01:00
4079638603 Add development dependency to yard for code documentation 2017-02-05 21:17:53 +01:00
728ac29432 Allow to push and pop new Buffers on the BufferStack 2017-02-04 01:19:56 +01:00
3078c7d4ca Use a different BufferStack per thread
That way, we can ensure that the BufferStack and the Buffers themselves
including their nested fields can not be accessed by different threads,
providing some thread safety for non malicious users.
2017-02-04 01:04:21 +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
5abf10af2b Add hard gem dependencies to concurrent-ruby and ref
Generally, we try hard to avoid additional dependencies to external gems
to keep us from having to maintain all these dependencies in the variety
of environments where Rackstash is going to be used.

We still decided to depend on two concurrent-ruby gems since they are

1. are of exceptional code quality
2. are well-maintained and with devs eager to maintain a stable and
   well-understood interface
3. provide very useful buolding-blocks for safe interoperations across
   thread-boundaries.

The chosen versions are selected to be compatible with a wide range of
external frameworks.
2017-02-04 00:11:13 +01:00
1f09b7b51f Test new/additional JRuby versions 2017-02-03 20:30:51 +01:00
e842d5c771 Automatically flush and clear a non-buffering Buffer after adding a message 2017-02-03 19:06:39 +01:00
cb4cdadd95 Add Buffer#flush to flush the current Buffer to the Sink 2017-02-03 19:05:44 +01:00
95c8b8f8fb Pass the sink from the Logger to each individual Buffer 2017-02-03 18:43:34 +01:00
bfe4cc854a Add Rackstash::Buffer#buffering? flag
Generally, a non-buffering Buffer will eventually be flushed to the sink
after each logged message. This thus mostly resembles the way
traditional loggers work in Ruby. A buffering Buffer however holds log
messages, fields and tags for a longer time. Only at a specific time,
all log messages and stored fields will be flushed to the Sink as a
single log event. A common scope for such an event is a full request to
a Rack app.
2017-02-03 14:54:50 +01:00
5e37df77e5 Add Rackstash::Buffer#clear to clear all data in a buffer 2017-02-03 14:21:22 +01:00
4db9fd7166 Add tests for Rackstash::Buffer#fields 2017-02-03 13:06:30 +01:00
8d2ea04c4f Set a timestamp on the Buffer 2017-02-03 00:28:45 +01:00
551b75c65d Add fields and tags to the Buffer
Each buffer instance can hold messages, fields and tags. These together
form the log event which will eventually be written to the log target.

By adding fields and tags, you can add highly details structured
information to your logs which allow to filter and analyze the logs
without having to parse complex multi-line logs.
2017-02-02 23:55:02 +01:00
95bf8430a9 Ignore blank tags 2017-02-02 23:45:24 +01:00
e9c98fc648 Allow to pass a scope with procs when merging Tags 2017-02-02 23:39:40 +01:00
0292a7eacb Resolve class ambiguity in Hash and Array constructors 2017-02-02 23:03:53 +01:00
94298fbbfd Add descriptions for subscript operators to Fields::Hash 2017-02-02 23:03:53 +01:00
f2cd5df554 Separate initialize_dup and initialize_copy in fields 2017-02-02 23:03:53 +01:00
b91a31335a Add empty? predicate to Fields::Array 2017-02-02 23:03:53 +01:00
e69818dd01 Add Tags field class to hold tags on a Buffer 2017-02-02 23:03:53 +01:00
0a011efc32 Don't rely on nil being frozen in tests
Turns out, in JRuby 9.1, nil is not frozen. In all other supported
Rubies, `nil.frozen?` is true.
2017-02-02 17:55:55 +01:00
7bc351faae Parse Time in tests with a numeric offset
Ruby's Time parser doesn't know named timezones and ignores them. By
specifying the actual offset, we get a valid time object.
2017-02-02 17:43:42 +01:00
407b52120a Add basic fields to hold additional data on Buffers
The fields follow the basic structure of basic Hashes and Arrays but
provide an interface better suitable for us. Specifically:

* They check and enforce the datatypes for keys and values to be
  strictly JSON-conforming. Only the basic data-types are accepted
  respectively converted to.
* Hashes only accept String keys.
* Basic values are always frozen.
2017-02-02 15:04:02 +01:00
8768630dbb Drop the default :each on before blocks in rspec 2017-02-02 00:23:31 +01:00
0465b11344 Improve code formatting of specs 2017-01-29 16:44:54 +01:00
faeddf8039 Replace usage of alias_method with alias in class body 2017-01-29 16:43:40 +01:00
5d1890bb5b Add to_json method to messages, don't freeze it anymore 2017-01-29 16:15:44 +01:00
52268c2a35 Use more compact rspec output by default. Also show Ruby's warnings 2017-01-27 14:49:01 +01:00
ee9feaa081 Resolve warning about ambiguous argument in logger spec 2017-01-27 14:42:37 +01:00