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`.
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.
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.
Unfortunately, there are still various edge-cases where things randomly
break due to TruffleRuby differences or incompatibilities to other gems.
This time, it was an incompatibility with a json gem update described in
https://github.com/oracle/truffleruby/issues/1857.
We will still try to keep Rackstash compatible with TruffleRuby but will
not consider full support for it release-critical for now.
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)
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...
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.
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.