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.63 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.62 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.61 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.60 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.59 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.58 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.57 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.55 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.54 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.53 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.52 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.51 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.50 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.49 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.47 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.46 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.45 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.44 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.43 lib/pwn/plugins/pwn_logger.rb
pwn-0.5.42 lib/pwn/plugins/pwn_logger.rb