Sha256: 041050276c2e070b5dde85b0fc0ae665913be42dbf8e1baace8e14d35435d225
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require "logger" require "securerandom" module Memolog extend self autoload :VERSION, "memolog/version" autoload :Config, "memolog/config" autoload :Extension, "memolog/extension" autoload :Formatter, "memolog/formatter" autoload :Middleware, "memolog/middleware" autoload :SentryScopeExtension, "memolog/sentry_scope_extension" autoload :SentrySidekiqMiddleware, "memolog/sentry_sidekiq_middleware" attr_accessor :debug, :logdevs self.debug = false self.logdevs = [] def configure @config ||= Memolog::Config.new yield(@config) if block_given? @config end alias config configure def extend_logger(other_logger) other_logger.extend(Memolog::Extension) other_logger.formatter = config.formatter end def logger Thread.current[:memolog_logger] ||= Logger.new(nil, formatter: config.formatter) end def uuid Thread.current[:memolog_uuid] end def run Thread.current[:memolog_uuid] = Memolog.config.uuid_callable.call logdevs.push(StringIO.new) logger.instance_variable_set(:@logdev, logdevs.last) yield ensure logdevs.pop unless debug end def dump return if logdevs.empty? beginning = logdevs.last.string.length - config.log_size_limit beginning = 0 if beginning.negative? logdevs.last.string.slice(beginning, config.log_size_limit) end end require "memolog/init"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
memolog-0.1.0 | lib/memolog.rb |