Sha256: f403e9c85a8e05328c2799d205d71fb0b0dbc4bda0254b13712eafafe92b52e4

Contents?: true

Size: 1.85 KB

Versions: 13

Compression:

Stored size: 1.85 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/logger/log'
require 'contrast/logger/cef_log'
require 'contrast/components/base'

module Contrast
  module Components
    module Logger # :nodoc:
      module InstanceMethods # :nodoc:
        def logger
          Contrast::Logger::Log.instance.logger
        end

        # When calling this method from any instance
        # The CEF logger will be initialized and it's
        # path and level will be set. Since we don't
        # call this method unless protect is started,
        # on Agent Startup no file is created before is
        # needed.
        #
        # @return [Logger]
        def cef_logger
          @_cef_logger ||= Contrast::Logger::CEFLog.instance.tap(&:build_logger)
        end
      end

      # So This class here follows the update for the configuration
      # and from know on ( if it's as we planned it to be) it will hold the
      # instance methods and will initialize new instances for where they're needed
      class Interface
        include InstanceMethods
        include Contrast::Components::ComponentBase

        CANON_NAME = 'agent.logger'
        CONFIG_VALUES = %w[path level progname].cs__freeze

        # @return [String, nil]
        attr_accessor :path
        # @return [String, nil]
        attr_accessor :level
        # @return [String, nil]
        attr_accessor :progname
        # @return [String]
        attr_reader :canon_name
        # @return [Array]
        attr_reader :config_values

        def initialize hsh = {}
          @config_values = CONFIG_VALUES
          @canon_name = CANON_NAME
          return unless hsh

          @path = hsh[:path]
          @level = hsh[:level]
          @progname = hsh[:progname]
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
contrast-agent-7.3.2 lib/contrast/components/logger.rb
contrast-agent-7.3.1 lib/contrast/components/logger.rb
contrast-agent-7.3.0 lib/contrast/components/logger.rb
contrast-agent-7.2.0 lib/contrast/components/logger.rb
contrast-agent-7.1.0 lib/contrast/components/logger.rb
contrast-agent-7.0.0 lib/contrast/components/logger.rb
contrast-agent-6.15.3 lib/contrast/components/logger.rb
contrast-agent-6.15.2 lib/contrast/components/logger.rb
contrast-agent-6.15.1 lib/contrast/components/logger.rb
contrast-agent-6.15.0 lib/contrast/components/logger.rb
contrast-agent-6.14.0 lib/contrast/components/logger.rb
contrast-agent-6.13.0 lib/contrast/components/logger.rb
contrast-agent-6.12.0 lib/contrast/components/logger.rb