Sha256: 0b0859f50cb9e4ec6e099ca656b2ba9bc3e98d0e935087aad74f35aa10ded418

Contents?: true

Size: 958 Bytes

Versions: 31

Compression:

Stored size: 958 Bytes

Contents

# To the extent possible under law, Eric Wong has waived all copyright and
# related or neighboring rights to this examples
#
# Multi-Processing-safe monkey patch for Logger
#
# This monkey patch fixes the case where "preload: true" is used and
# the application spawns a background thread upon being loaded.
#
# This removes all lock from the Logger code and solely relies on the
# underlying filesystem to handle write(2) system calls atomically when
# O_APPEND is used.  This is safe in the presence of both multiple
# threads (native or green) and multiple processes when writing to
# a filesystem with POSIX O_APPEND semantics.
#
# It should be noted that the original locking on Logger could _never_ be
# considered reliable on non-POSIX filesystems with multiple processes,
# either, so nothing is lost in that case.

require 'logger'
class Logger::LogDevice
  def write(message)
    @dev.syswrite(message)
  end

  def close
    @dev.close
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
yahns-1.18.0 examples/logger_mp_safe.rb
yahns-1.17.0 examples/logger_mp_safe.rb
yahns-1.16.0 examples/logger_mp_safe.rb
yahns-1.15.0 examples/logger_mp_safe.rb
yahns-1.14.1 examples/logger_mp_safe.rb
yahns-1.14.0 examples/logger_mp_safe.rb
yahns-1.13.0 examples/logger_mp_safe.rb
yahns-1.12.5 examples/logger_mp_safe.rb
yahns-1.12.4 examples/logger_mp_safe.rb
yahns-1.12.3 examples/logger_mp_safe.rb
yahns-1.12.2 examples/logger_mp_safe.rb
yahns-1.12.1 examples/logger_mp_safe.rb
yahns-1.12.0 examples/logger_mp_safe.rb
yahns-1.11.0 examples/logger_mp_safe.rb
yahns-1.10.0 examples/logger_mp_safe.rb
yahns-1.9.0 examples/logger_mp_safe.rb
yahns-1.8.0 examples/logger_mp_safe.rb
yahns-1.7.0 examples/logger_mp_safe.rb
yahns-1.6.0 examples/logger_mp_safe.rb
yahns-1.5.0 examples/logger_mp_safe.rb