Sha256: a072cc51d083f7a31575c3e87b7dc6a743d61055f18ec4a38bd269c1ed81dafc

Contents?: true

Size: 1.57 KB

Versions: 470

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

require 'logger'

module PWN
  module Plugins
    # This plugin is used to instantiate a PWN logger with a custom message format
    module PWNLogger
      # Supported Method Parameters::
      # PWN::Plugins::PWNLogger.create(
      # )

      public_class_method def self.create(opts = {})
        logger = Logger.new($stdout)
        level = opts[:level]

        case level.to_s.downcase.to_sym
        when :debug
          logger.level = Logger::DEBUG
        when :error
          logger.level = Logger::ERROR
        when :fatal
          logger.level = Logger::FATAL
        when :unknown
          logger.level = Logger::UNKNOWN
        when :warn
          logger.level = Logger::WARN
        else
          logger.level = Logger::INFO
        end

        logger.datetime_format = '%Y-%m-%d %H:%M:%S.%N'

        logger.formatter = proc do |severity, _datetime, _progname, msg|
          # TODO: Include datetime & progname vars
          "[#{severity}] #{msg}\n"
        end

        logger
      rescue StandardError => e
        raise e
      end

      # Author(s):: 0day Inc. <request.pentest@0dayinc.com>

      public_class_method def self.authors
        'AUTHOR(S):
          0day Inc. <request.pentest@0dayinc.com>
        '
      end

      # Display Usage for this Module

      public_class_method def self.help
        puts "USAGE:
          logger = #{self}.create(
            level: 'optional - logging verbosity :debug|:error|:fatal|:info|:unknown|:warn (Defaults to :info)'
          )
          #{self}.authors
        "
      end
    end
  end
end

Version data entries

470 entries across 470 versions & 1 rubygems

Version Path
pwn-0.5.41 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.40 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.39 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.38 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.37 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.36 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.35 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.34 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.33 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.32 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.31 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.30 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.29 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.28 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.27 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.26 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.25 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.24 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.23 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.22 lib/pwn/plugins/pwn_logger.rb