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

297 Commits

Author SHA1 Message Date
04b75bd748 Don't add trailing newline in Rackstash::Formatter
Instead, let the encoders (and if necessary the adapters) add newlines
if necessary.

This makes it more straight-forward to filter messages and eventually
allows the encoders to format messages with fewer checks. Finally, we
might avoid the creation a lot of intermediary strings.
2020-08-09 14:00:39 +02:00
bb78d98639 Remove unused RawFormatter 2020-08-09 14:00:39 +02:00
718e2c026a Create an lcov file for coverage instead of the automatic simplecov formatter for coveralls 2020-07-23 16:29:34 +02:00
7e54d70270 Handle plain absolute Windows paths gracefully for adapter creation
A absolute Windows path such as `C:/path.to/file.log` is a valid URL
with schema `C`. If a user specifies such a path, they likely want to
create a File adapter in this case. As such, we fallback from
`Adapter.adapter_by_uri_scheme` and create File adapter instance via
`Adapter.adapter_by_type`.
2020-07-23 16:10:57 +02:00
65bf5ae252 Be more strict when parsing URIs for adapter creation
We require correct case of the schema and we no longer use the opaque
part (which appears to have been a bug anyways at this place)
2020-07-23 16:10:57 +02:00
0e0cb7dbae Use a more generic detection of a CI environment for coveralls in specs 2020-07-23 16:10:36 +02:00
a8911dbbd7 Fix Rackstash::Utils.clock_time on newer Windows versions 2020-07-10 20:40:05 +02:00
08ca86b7c3 Explicitly require rack/mock in rack middleware spec 2020-07-10 18:51:07 +02:00
42500162fb Allow to clone and dup a ClassRegistry object 2020-07-10 17:56:46 +02:00
76731b1d77 Improve error messages for ClassRegistry 2020-07-10 17:56:46 +02:00
ef57352e1f Combine rackstash helpers into one Rackstash::Utils module 2020-07-10 17:30:46 +02:00
c5206b407f Allow filter conditionals to be defined as symbols too 2020-06-07 16:44:53 +02:00
7fe284309b Remove scope parameter from Logger#tag and Buffer#tag
This reduces the change of a Hash argument being interpreted as keyword
argument inadvertently and clarifies the interface. If a resolver scope
is required, you can also call

    delayed_tag = ->{ |request| request.host }
    logger.tags.merge!(delayed_tag, scope: request)
2019-10-07 19:58:20 +02:00
b3466779bb Fix test to ensure that hashes passed to Buffer#tag are actually stringified 2019-10-07 19:50:29 +02:00
706b391176 Don't fail tests if local timezone is UTC 2019-09-25 16:25:16 +02:00
e3baeb377e Skip file rename tests on Windows on older Ruby versions
Since these platforms don't support the File::SHARE_DELETE flag on
files, Windows rejects any attempts to delete or rename a file opened
by us. There's nothing we can do here unfortunately...
2019-09-25 16:25:16 +02:00
6831e3db55 Allow to acquire an exclusive lock on the logfile for each write to a file
This is required on Windows (where we enable this feature by default)
since they don't support concurrent atomic writes above the drive's
sector size (usually between 512 Bytes and 4 KiBytes). Without an
explicit lock, concurrent writes can be interleaved or be partially
lost.
2019-09-25 16:25:16 +02:00
0907a85e81 Use a Concurrent::CyclicBarrier instead of file locking for concurrent file adapter tests 2019-09-25 16:25:15 +02:00
f304f04ded Always run concurrency tests for File adapter with threads
Since fork is not available on some platforms (aka. Windows), we
avoid it and use normal Threads instead. We have fail saves in place to
ensure that tests are still valid even on MRI with its GIL.
2019-09-17 22:26:07 +02:00
c79f2e45d3 Close a tempfile before attemting to rename it in File specs
This is required on Windows which stubornly refused to rename opened
files by default.
2019-09-17 22:26:07 +02:00
68d674668a Explicitly remove temporary files in specs 2019-09-17 22:26:07 +02:00
b6be188dbd Use Logger#capture instead of with_buffer as a more intention revealing name 2019-01-14 11:51:05 +01:00
26a1ce0a68 Log the original event to the error_flow if Flow#write raises an error 2018-12-05 18:54:27 +01:00
0967593010 Perform actions on flows asynchronously by default
Each flow now has an associated executor which performs all actions
(writing events, closing, reopening) asynchronously by default using a
Concurrent::SingleThreadExecutor.

This improves the responsiveness of the application by performing the
(usually) IO-bound task of writing the logs to a background thread.

By creating a flow with `synchronous: true`, all actions are run in the
calling thread as before, making the flow blocking.
2018-12-05 18:51:29 +01:00
8a19dea76c Rename the DropIf filter to Drop and allow it to drop a percentage of events
With this, we also drop the ability to define conditions in the filter
itself. When adding a filter, users can still setup a condition using
the common functionality of all filters.
2018-08-28 10:33:20 +02:00
9152b67df0 Allow to pass initializer arguments to the encoder of a flow 2018-07-18 12:47:55 +02:00
a3f16b42cd Add attribute reader for tagged fields to Encoder::Message 2018-07-18 12:33:10 +02:00
b646ef9ef1 Add Rack::Errors#close to satisfy the expected protocol for a logdev of Ruby's core Logger 2018-07-17 22:53:54 +02:00
f97bcf2334 Add Flow#raise_on_error! as a convenience method 2018-07-17 22:49:32 +02:00
d510280532 Preserve existing field mappings for encoder fields 2018-07-17 21:39:37 +02:00
3ef0d56c2d Bug: Allow Flows#auto_flush if there are only auto_flushing flows 2018-07-12 18:20:34 +02:00
2c7d897889 Allow to set a registered encoder in a Flow by name 2018-07-12 18:02:09 +02:00
a807f99af5 Interpret a Date in the Gelf timestamp field as UTC midnight 2018-06-15 00:12:51 +02:00
916cabd43d Add Gelf encoder to create logs in the Graylog Extended Log Format 2018-06-14 23:54:36 +02:00
fcb1043b6f Correctly format date and time objects in Lograge encoder 2018-06-14 23:51:40 +02:00
5e9c76d6df Allow to rotate log files using a date-based pattern
We now support two different modes of file rotation at the same time:

* auto_reopen can be used to automatically reopen a logfile at the
  original location if the file was moved or deleted from the filesystem
* rotate can be used to write to a rotate file which can be reopened /
  created based on Date pattern.

The user can now decide whether they want to use an external logrotate
command or use internal rotation with Rackstash instead.
2018-06-13 22:33:47 +02:00
a99f182715 Format UNIX timestamps in encoders and preserve pre-formatted Strings 2018-05-16 21:36:24 +02:00
a3d66deb7a Preserve the frozen state when cloning Flows objects 2018-05-16 21:01:10 +02:00
cdc237897f Add a shortcut to enable auto_flush on a Flow with Flow#auto_flush! 2018-05-16 20:46:59 +02:00
d502bece9c Add tests for Flow#auto_flush 2018-05-16 20:44:42 +02:00
3b5ff3a4dc Normalize fields more consistently in encoders 2018-04-19 22:54:16 +02:00
5c626f984b Always add buffering buffers with the Rack middleware 2018-04-10 22:44:25 +02:00
6b4f009107 Introduce auto_flushing Flows to simplify the buffering behavior of Buffers
Instead of defining the specific buffering behavior on a Buffer, we can
now mark individual flows as auto_flushing or now. An auto_flushing Flow
with a buffering Buffer behaves the same as a Buffer with `buffering:
:data` would before.

This allows us to simplify the buffering logic on the Buffer. Also, we
can now use "normal" flows and auto_flushing flows on the same logger in
parallel. Each of them behaves as expected with the same unchanged logger
code.

It is thus easier to define behavior for a development or production
environment of an app since the necessary changes can all be defined on
the logger itself (through the defined flows) without having to adapt
the code which creates suitable Buffers with the Logger#with_buffer
method in any way.
2018-04-10 22:44:25 +02:00
88d50afbf9 Write the raw buffer to the event on flush and use #to_h instead of #to_event to create the event
With that, we can lazy-transform the Buffer to the event hash. B using
the common `.to_h` protocol, we can also support various other objects
here instead of just Buffers (including actual raw Hashes).
2018-03-02 20:10:33 +01:00
5e29b7f912 Enfore RSpec expect syntax 2018-02-15 16:04:34 +01:00
dab393ee21 Disable moneky patching with RSpec 2018-02-15 16:03:13 +01:00
8c9b564f54 Allow to modify a filter chain instance by specifying registered filter names as a Symbol 2018-02-10 21:30:42 +01:00
42d120561b Clarify the error message when trying to fetch invalid specs from a ClassRegistry 2018-02-10 14:12:11 +01:00
2d04ccb6c9 Add ClassRegistry#fetch and change ClassRegistry#[] to return nil if no class was found 2018-02-10 14:08:20 +01:00
21e0c5a228 Rename the filename to paht in file adapter 2018-02-06 20:32:31 +01:00