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

354 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
1249b6ac47 Fix typo in documentation for Rackstash::Utils.utf8 2020-08-04 17:58:34 +02:00
e4a690f6cc Enable Adapter::File#lock on Windows by default again 2020-07-23 16:10:57 +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
f231d226d0 Do not lock files with flock by default anymore
Newer Windows versions (i.e. >= 10.0.14393) apparently follow POSIX more
strictly. With current Windows and Linux versions, we can thus get away
with just writing to the file and depending on the OS to properly
serialize those writes.

On older versions or with some network filesystems, the user might still
have to enable file locking if they are writing to the same log file
from multiple processes.
2020-07-10 20:40:05 +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
eaa13c8111 Dup object_type for class registry only if required 2020-07-10 17:46:25 +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
27847ac6ef Ensure the stored object_type of a ClassRegistry is always frozen 2020-06-07 16:44:13 +02:00
aa5a496a18 Fix rubocop style issues 2020-06-07 14:22:14 +02:00
9e92e706bf Don't mix hash arguments with keyword arguments
Since Ruby 2.7 differences explicit keyword arguments from implicit hash
arguments, we should also avoid mixing them. By using explicit keyword
arguments, we avoid warning in Ruby 2.7 and errors in Ruby 3.0.
2019-12-18 12:56:29 +01: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
7f5337c0e2 Refactor exclusive file locking and include error handling 2019-10-02 16:29:17 +02:00
8943e18aca Correctly parse opaque URLs for the File adapter 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
0f8bdd0be0 Open output files with File::SHARE_DELETE to allow logrotates on Windows 2019-09-17 19:02:30 +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
2d5fe79d7a Automatically require the Select filter class 2018-08-28 10:36:19 +02: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
9604ebf484 Correctly describe the encoder build process in the docs for Encoder.build 2018-07-18 12:47:55 +02:00
ba0aef3283 Fix typo in Filter.build documentation 2018-07-18 12:43:30 +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
78f3e037e7 Add method reference to docs for Message#initialize 2018-07-17 22:51:30 +02:00
f97bcf2334 Add Flow#raise_on_error! as a convenience method 2018-07-17 22:49:32 +02:00
e592434eec Do not mention local methods of Buffer class in methods docs referenced by Logger 2018-07-17 22:46:15 +02:00
d510280532 Preserve existing field mappings for encoder fields 2018-07-17 21:39:37 +02:00
3167574607 Correctly name the GELF full_message field (omitted by default) 2018-07-17 19:00:51 +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
fa1abb5ab5 Define UndefinedClass as an actual Singleton
This takes care of edge-cases and ensures that multiple loads of
`lib/rackstash.rb` do not fail on an attempted second initialization of
the UndefinedClass.
2018-06-21 13:56:50 +02:00
a807f99af5 Interpret a Date in the Gelf timestamp field as UTC midnight 2018-06-15 00:12:51 +02:00
a70b859a53 Update copyright 2018-06-14 23:57:14 +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
bb4d8e10bb Clearify buffering behavior on Rackstash::Buffer 2018-06-13 22:51:06 +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
7713bdfdb6 Allow to customize the final newline character when writing to an adapter 2018-05-31 20:12:59 +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
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