Sha256: 767473b98b28e87d9468f9d5f973be7183513643e6350d2e963857698ba28b31
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require "logger" require "securerandom" require "stringio" require "memolog/version" require "memolog/config" require "memolog/extension" require "memolog/formatter" require "memolog/init" require "memolog/middleware" require "memolog/sentry_scope_extension" require "memolog/sentry_sidekiq_middleware_extension" module Memolog extend self attr_accessor :config, :logdevs @config = Memolog::Config.new @logdevs = [] def configure yield(config) if block_given? end def init! Memolog::Init.new.call end def extend_logger(other_logger) other_logger.extend(Memolog::Extension) other_logger.formatter = config.formatter end def uuid Thread.current[:memolog_uuid] end def logger Thread.current[:memolog_logger] ||= Logger.new(nil, formatter: config.formatter) end def run Thread.current[:memolog_uuid] = config.uuid_callable.call logdevs.push(StringIO.new) logger.instance_variable_set(:@logdev, logdevs.last) yield ensure logdevs.pop unless config.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).presence end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
memolog-0.3.0 | lib/memolog.rb |